我们如何抑制tshark默认输出

时间:2013-11-15 02:53:15

标签: linux tshark

我们如何抑制tshark默认输出。有关更多详细信息,请参阅下面给出的示例输出:

system@client:~$ sudo tshark -q -i eth0 -f "tcp" -a duration:3 -w /tmp/test.pcap
[sudo] password for system:
tshark: Lua: Error during loading:
 [string "/usr/share/wireshark/init.lua"]:45: dofile has been disabled
Running as user "root" and group "root". This could be dangerous.
Capturing on eth0
2 packets captured
system@client:~$

=============================================== ====================

试验台:

客户< --------------->服务器

代码示例:

        def execTShark(self,cmd):
            try:
                    self.SSHCONN.sendline('')
                    self.SSHCONN.expect('[#\$>]')
                    self.SSHCONN.maxread=20000
                    self.output = ""
                    self.SSHCONN.sendline( cmd )
                    while 1:
                            i       = self.SSHCONN.expect (['password', '[#\$>]'])
                            self.output       =       self.output + self.SSHCONN.before
                            if i==0:
                                    self.SSHCONN.sendline(self.password)
                            elif i==1:
                                    self.SSHCONN.sendline('')
                                    self.SSHCONN.expect (['[#\$>]', 'Capturing'])
                                    self.output       =       self.output + self.SSHCONN.before
                                    self.SSHCONN.sendline('')
                                    break
                    self.SSHCONN.expect('[#\$>]')
                    self.output       =       self.output + self.SSHCONN.before
                    print self.output
            except Exception as ex:
                    print("An exception occurred, " + str(ex))
                    return False
            return True

问题:

1.当我调用上面提到的函数时,execTShark的cmd =“sudo tshark -q -i eth0 -f”tcp“-a duration:3 -w /tmp/test.pcap&”,有时它在等待这条消息“捕获eth0”时失败了。

0 个答案:

没有答案