我啟動了一個在 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 加密的電視頻道。
uj5u.com熱心網友回復:
這可能是你想要的:
#!/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
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/407349.html
標籤:
上一篇:文本格式化為特定寬度
下一篇:如何添加從管道出來的字串
