Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 |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 |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 Aug 17 '11 at 20:01

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

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


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