Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to keep a trace of the URL I visit, so I use a command line like this:

tcpdump -ien1 -v -X 'tcp port 80' | sed -nl 's/^.0x[0-9a-f]{4}:.{43}(.)$/\1/p' |perl break.pl |perl -pe 's/(GET|POST).(.*?).HTTP/1....Host:.([a-zA-Z._0-9-]*)../"\nBEGURL ".localtime().": $1 http://$3$2\n"/ge' | grep "^BEGURL"

It's working fine, one URL per line. But if I do

tcpdump -ien1 -v -X 'tcp port 80' | sed -nl 's/^.0x[0-9a-f]{4}:.{43}(.)$/\1/p' |perl break.pl |perl -pe 's/(GET|POST).(.*?).HTTP/1....Host:.([a-zA-Z._0-9-]*)../"\nBEGURL ".localtime().": $1 http://$3$2\n"/ge' | grep "^BEGURL" >> /tmp/out

(notice the end >> /tmp/out) Then file is empty! Do you know why? It's totally illogical for me.

I also tried redirecting stdout and stderr to /tmp/out, it's still empty. The file has write access. I have no idea what it can be. Is there anything else than stdout and stderr??

for any help.

share|improve this question

migrated from stackoverflow.com Aug 17 '11 at 20:01

This question came from our site for professional and enthusiast programmers.

2 Answers 2

You might mean that you've tried this, when you say "I also tried redirecting stdout and stderr to /tmp/out" - but it seems like the most likely problem: so try adding 2>&1 to the end.

If not then to help to debug try adding 2>/dev/null to your first command and see if you still get output.

Also, can you simplify the command for testing? For example, does this work:

tcpdump -ien1 -v -X 'tcp port 80' >> /tmp/out
share|improve this answer

I had the same problem just a few days ago. Try using the -w option, to write the packets to a file. For more information see man tcpdump.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.