我正在尝试让 cronjob
使用 tshark
转换文件。
到目前为止,这是我的脚本:
files=$(find /home/user/traces/*.pcap -mmin +10 -type f)
echo "$files" | tshark -r - -T ek > '/home/user/traces/converted/'-.json
我正在尝试转换超过 10 分钟的文件,并将它们放在 converted
文件夹中。
但它失败了:
tshark: The standard input isn't a capture file in a format TShark understands.
我认为将文件名传递给 tshark
失败了,但不确定。
作为引用,这个命令确实有效:
tshark -r /home/user/traces/trace.pcap -T ek > /home/user/traces/converted/trace.pcap.json
更新
似乎可以使用 for 循环:
files=$(find /home/user/traces/*.pcap -mmin +10 -type f)
for file in $files
do
echo "processing file: $file"
tshark -r $file -T ek > "$file.json"
done
最佳答案
$files 逐行包含文件。我相信不能用 echo "$files"| 捕获多个文件。 tshark -r -
。
看来你需要有循环
IFS=$'\n' # make newlines the only separator
for f in $files
do
...
done
关于linux - 通过命令 shell 脚本使用 tshark 进行转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54786776/