Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从bash脚本执行tshark命令_Bash_Shell_Sh_Wireshark - Fatal编程技术网

如何从bash脚本执行tshark命令

如何从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.

我正在尝试执行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.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[@]}"