I'm trying to run the following:
$ tcpdump -l -X -i eth1 -n tcp port <port> | tee capture.txt | \
scp capture.txt root@10.3.3.227:/home/checker/
tcpdump -l -X -i eth1 -n tcp port <port>
In step #1 I'm capturing packets, using "-l" to to make standard out line-buffered, so that it will write each packet as it arrives.
tee capture.txt
In step #2
man tee
: "The tee utility copies standard input to standard output, making a copy in zero or more files." The output is unbuffered.scp capture.txt root@<remote-IP>:/home/
In step #3 I'm send the capture.txt file to a remote host.
The problem
If I simply perform steps #1 and #2, ALL packets are captured on the specified port. However, if I also use step #3 the capture.tx
t does NOT contain all the packets (only a few)... This is killing me because I had this running OK just a few minutes ago!
What is wrong here?
The capute.txt file that is sent to the remote host, on a second run of the tcpdump, is incremented instead of replaced...
How do I overcome this?
– bulkmoustache Oct 24 '13 at 01:06tcpdump -l | tee /dev/tty | ssh root@remotehost "cat > /tmp/capture.txt"
I've tried to "echo /dev/null > capture" and "rm" the capture.txt but none of these are working =\ The file on the remote host keeps incrementing...
– bulkmoustache Oct 24 '13 at 02:17The last part is to make sure the temp.txt is erased and, on the next tcpdump iteration, it is not incremented but instead written as a brand new file. But so far, this is not working (guess the cp is not working properly). Any ideias to copy a file's content into another?
– bulkmoustache Oct 24 '13 at 02:43