1. <small id='mZxgF'></small><noframes id='mZxgF'>

      <legend id='mZxgF'><style id='mZxgF'><dir id='mZxgF'><q id='mZxgF'></q></dir></style></legend>
        <bdo id='mZxgF'></bdo><ul id='mZxgF'></ul>
        <tfoot id='mZxgF'></tfoot>

      1. <i id='mZxgF'><tr id='mZxgF'><dt id='mZxgF'><q id='mZxgF'><span id='mZxgF'><b id='mZxgF'><form id='mZxgF'><ins id='mZxgF'></ins><ul id='mZxgF'></ul><sub id='mZxgF'></sub></form><legend id='mZxgF'></legend><bdo id='mZxgF'><pre id='mZxgF'><center id='mZxgF'></center></pre></bdo></b><th id='mZxgF'></th></span></q></dt></tr></i><div id='mZxgF'><tfoot id='mZxgF'></tfoot><dl id='mZxgF'><fieldset id='mZxgF'></fieldset></dl></div>
      2. 在 python 中处理 tcpdump 输出

        Handling tcpdump output in python(在 python 中处理 tcpdump 输出)
        <legend id='ydJvC'><style id='ydJvC'><dir id='ydJvC'><q id='ydJvC'></q></dir></style></legend>

            • <bdo id='ydJvC'></bdo><ul id='ydJvC'></ul>

              <small id='ydJvC'></small><noframes id='ydJvC'>

                  <tfoot id='ydJvC'></tfoot>

                1. <i id='ydJvC'><tr id='ydJvC'><dt id='ydJvC'><q id='ydJvC'><span id='ydJvC'><b id='ydJvC'><form id='ydJvC'><ins id='ydJvC'></ins><ul id='ydJvC'></ul><sub id='ydJvC'></sub></form><legend id='ydJvC'></legend><bdo id='ydJvC'><pre id='ydJvC'><center id='ydJvC'></center></pre></bdo></b><th id='ydJvC'></th></span></q></dt></tr></i><div id='ydJvC'><tfoot id='ydJvC'></tfoot><dl id='ydJvC'><fieldset id='ydJvC'></fieldset></dl></div>
                    <tbody id='ydJvC'></tbody>

                  本文介绍了在 python 中处理 tcpdump 输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试在 python 中处理 tcpdump 输出.

                  Im trying to handle tcpdump output in python.

                  我需要的是运行 tcpdump(它捕获数据包并为我提供信息)并读取输出并处理它.

                  What I need is to run tcpdump (which captures the packets and gives me information) and read the output and process it.

                  问题是 tcpdump 一直在运行,我需要在它输出后立即读取数据包信息并继续执行.

                  The problem is that tcpdump keeps running forever and I need to read the packet info as soon as it outputs and continue doing it.

                  我尝试查看 python 的子进程并尝试使用 popen 调用 tcpdump 并通过管道传输标准输出,但它似乎不起作用.

                  I tried looking into subprocess of python and tried calling tcpdump using popen and piping the stdout but it doesnt seem to work.

                  有关如何进行此操作的任何说明.

                  Any directions on how to proceed with this.

                  import subprocess
                  
                  def redirect():
                      tcpdump = subprocess.Popen("sudo tcpdump...", stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
                      while True:
                          s = tcpdump.stdout.readline()
                          # do domething with s
                  
                  redirect()
                  

                  推荐答案

                  您可以使用-l"使 tcpdump 行缓冲.然后你可以使用 subprocess 来捕获输出.

                  You can make tcpdump line-buffered with "-l". Then you can use subprocess to capture the output as it comes out.

                  import subprocess as sub
                  
                  p = sub.Popen(('sudo', 'tcpdump', '-l'), stdout=sub.PIPE)
                  for row in iter(p.stdout.readline, b''):
                      print row.rstrip()   # process here
                  

                  这篇关于在 python 中处理 tcpdump 输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)

                  <i id='kG2xF'><tr id='kG2xF'><dt id='kG2xF'><q id='kG2xF'><span id='kG2xF'><b id='kG2xF'><form id='kG2xF'><ins id='kG2xF'></ins><ul id='kG2xF'></ul><sub id='kG2xF'></sub></form><legend id='kG2xF'></legend><bdo id='kG2xF'><pre id='kG2xF'><center id='kG2xF'></center></pre></bdo></b><th id='kG2xF'></th></span></q></dt></tr></i><div id='kG2xF'><tfoot id='kG2xF'></tfoot><dl id='kG2xF'><fieldset id='kG2xF'></fieldset></dl></div>

                  <small id='kG2xF'></small><noframes id='kG2xF'>

                      <tbody id='kG2xF'></tbody>

                          • <bdo id='kG2xF'></bdo><ul id='kG2xF'></ul>
                          • <tfoot id='kG2xF'></tfoot>

                            <legend id='kG2xF'><style id='kG2xF'><dir id='kG2xF'><q id='kG2xF'></q></dir></style></legend>