我正在使用 linux pc 并安装了 tshark 。并且必须使用 TCL 脚本在 eth1 接口中捕获数据包。但是 tshark 以 root 模式运行。捕获和运行 pc 的脚本是相同的。如何以 root 身份登录以及如何使用 TCL 运行 tshark 命令?请为此提供解决方案。
#!/usr/bin/tclsh
set out [exec tshark -V -i eth1 arp -c 1 ]
puts $out
输出
test@test:~$ tclsh pcap.tcl
Capturing on eth1
tshark: The capture session could not be initiated (eth1: You don't have permission to capture on that device (socket: Operation not permitted)).
Please check to make sure you have sufficient permissions, and that you have the proper interface or pipe specified.
0 packets captured
while executing
"exec tshark -V -i eth1 arp -c 1 "
invoked from within
"set out [exec tshark -V -i eth1 arp -c 1 ]"
(file "pcap.tcl" line 5)
test@test:~$