如何从bash脚本执行tshark命令
我正在尝试执行tshark命令,以便在bash命令中查找特定IP地址的数据包,如下所示:如何从bash脚本执行tshark命令,bash,shell,sh,wireshark,Bash,Shell,Sh,Wireshark,我正在尝试执行tshark命令,以便在bash命令中查找特定IP地址的数据包,如下所示: while read client do echo "Client Adrees:" $client1 cmd="tshark -R \"(ip.src == 10.129.5.192)\" -r 12clients.pcap" echo $cmd done < input Client Adrees: 10.129.26.154 tshark -R "(ip.src == 10.129.
while read client
do
echo "Client Adrees:" $client1
cmd="tshark -R \"(ip.src == 10.129.5.192)\" -r 12clients.pcap"
echo $cmd
done < input
Client Adrees: 10.129.26.154
tshark -R "(ip.src == 10.129.5.192)" -r 12clients.pcap
tshark: Read filters were specified both with "-R" and with additional command-line arguments
提前感谢…:D使用数组变量来存储和执行命令-使用带有文字双引号的单个字符串将无法正确解释:
# Store command tokens in an array.
# Note that each word or quoted phrase will form a separate array element.
cmd=( tshark -R "(ip.src == 10.129.5.192)" -r 12clients.pcap )
# Invoke command as the expanded array.
# Double-quoting it prevents shell expansions of the elements.
"${cmd[@]}"