bash 用于对函数的 return 字符串进行排序的脚本
bash script to sort the return strings of a function
我在 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 加密的电视频道。
这可能是您想要的:
#!/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
我在 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 加密的电视频道。
这可能是您想要的:
#!/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