0

如何将此命令的实时流输出保存到在 while 循环中逐行运行的变量/连接?就像是:

netvalue <-system("tcpdump -A -i eth0 port 80 | grep foo")
while(T) {
...
nvar <- netvalue + othervalue
...
}

或者

In a terminal: 
$ tcpdump ... | grep --line-buffered [myterm] > fifofile

Then in R:
> con = fifo("fifofile", "r")
> open(con, "r")
> con
  description    class        mode        text      opened    can read
     "fifo"      "fifo"         "r"      "text"    "opened"       "yes"
  can write
    "no"    
> readLines(con, n = 1)
> [myterm]

.. but it only works sometimes, and often 
for a limited term, when it fails always returning:

> character(0)

在 readLines(con, n = -1) 中使用“-1”参数清除整个 fifofile 似乎会持续地终止连接!?

4

1 回答 1

0

tcpdump 提供带有“-w 文件名”参数的 pcap 文件输出。

您可以使用此方法将数据存储在文件中,并使用带有 python 或 R 的替代脚本逐行读取它。

于 2015-09-15T06:36:48.297 回答