How do I save the live streaming output of this command to a variable/connection line-by-line running in a while loop? Something like:
netvalue <-system("tcpdump -A -i eth0 port 80 | grep foo")
while(T) {
...
nvar <- netvalue + othervalue
...
}
OR
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)
Purging the entire fifofile with the "-1" argument in readLines(con, n = -1) seems to kill the connection consitently!?