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 filename」パラメーターを使用して pcap ファイル出力を提供します。

この方法を使用してデータをファイルに保存し、Python または R で代替スクリプトを使用して、そこから行ごとに読み取ることができます。

于 2015-09-15T06:36:48.297 に答える