0

我启动了一个在 linux 卫星接收器上运行的脚本并运行“ dvbsnoop ”工具。我需要帮助来完成脚本,因为我不知道如何处理来自“dvbsnoop”工具的结果。

#!/bin/bash

# Asign to variable 'b' the service reference for wanted TV channel
b="1:0:1:5A:65:1:FFFF0000:0:0:0:"

# Acces the web interface and set requested TV channel 
wget -q -O - "http://127.0.0.1/web/zap?sRef=$b"

# Sniff data stream with dvbsnoop tool (1 packet and nohexdumpbuffer)
dvbsnoop -n 1 -nph 1

#
# HELP ME HERE
#
# 'dvbsnoop' will return a list of CA_system_ID and other informations
# It could be one CA_system_ID, more than one or none.
# Example: CA_system_ID: 6272 (0x1880), CA_system_ID: 1723 (0x06bb), CA_system_ID: 6260 (0x1874)
# The only information that i'm interested is between brackets: (0x1880), (0x06bb), (0xXXXX), etc
# 
# the variable 'b' should then be  stored in a filename. 
# (preferably named after the value of CA_system_ID, for example CAiD_0x1880.txt). 
# The script should creates the file if not present, otherwise appends to it.
# 
# If 'dvbsnoop' return more than one CA_system_ID then the variable 'b' should be added in multiple files.
# 
# The text #SERVICE must preceded de content of variable 'b' in the file.
# 
# Example:
# File name: CAiD_0x1880.txt
# File content after run of the script: #SERVICE 1:0:1:5A:65:1:FFFF0000:0:0:0:
# 

运行 ' dvbsnoop -n 1 -nph 1' 后,输出如下所示:

dvbsnoop V1.4.56 -- https://github.com/OpenVisionE2/dvbsnoop

------------------------------------------------------------
SECT-Packet: 00000001   PID: 1 (0x0001), Length: 36 (0x0024)
Time received: Sat 2022-01-08  18:38:44.926
------------------------------------------------------------
PID:  1 (0x0001)  [= assigned for: ISO 13818-1 Conditional Access Table (CAT)]

Guess table from table id...
CAT-decoding....
Table_ID: 1 (0x01)  [= Conditional Access Table (CAT)]
section_syntax_indicator: 1 (0x01)
(fixed): 0 (0x00)
reserved_1: 3 (0x03)
Section_length: 33 (0x0021)
reserved_2: 262143 (0x3ffff)
Version_number: 5 (0x05)
current_next_indicator: 1 (0x01)  [= valid now]
Section_number: 0 (0x00)
Last_Section_number: 0 (0x00)

        MPEG-DescriptorTag: 9 (0x09)  [= CA_descriptor]
        descriptor_length: 4 (0x04)
        CA_system_ID: 6145 (0x1801)  [= Kudelski SA]
        reserved: 7 (0x07)
        CA_PID: 129 (0x0081)

        MPEG-DescriptorTag: 9 (0x09)  [= CA_descriptor]
        descriptor_length: 4 (0x04)
        CA_system_ID: 6272 (0x1880)  [= Kudelski SA]
        reserved: 7 (0x07)
        CA_PID: 131 (0x0083)

        MPEG-DescriptorTag: 9 (0x09)  [= CA_descriptor]
        descriptor_length: 4 (0x04)
        CA_system_ID: 1723 (0x06bb)  [= Irdeto]
        reserved: 7 (0x07)
        CA_PID: 134 (0x0086)

        MPEG-DescriptorTag: 9 (0x09)  [= CA_descriptor]
        descriptor_length: 4 (0x04)
        CA_system_ID: 6260 (0x1874)  [= Kudelski SA]
        reserved: 7 (0x07)
        CA_PID: 135 (0x0087)

CRC: 1088558619 (0x40e2161b)
==========================================================

该脚本的重点是对使用相同加密系统的电视频道进行排序并存储在文件中。我提到过,这个脚本将在 Linux 卫星电视接收器上运行,生成的文件将用作收藏的电视频道列表。如果我在接收器中插入带有 CAiD 1880 的智能卡,那么我只想访问使用 1880 加密的电视频道。

4

1 回答 1

0

这可能是你想要的:

#!/bin/bash

b='1:0:1:5A:65:1:FFFF0000:0:0:0:'
re='CA_system_ID:.*\((0x[[:xdigit:]]+)\)'

dvbsnoop -n 1 -nph 1 |
while read -r line; do
    if [[ $line =~ $re ]]; then
        echo "#SERVICE $b" >> "CAiD_${BASH_REMATCH[1]}.txt"
    fi
done
于 2022-01-08T18:12:44.447 回答