I want to run a TCP program and capture related packets, my shell cap.sh script looks like this:
sudo tcpdump -i eth0 -w mypcap & sleep 3 ./tcp_receiver sleep 2 x=`ps -ef|grep "tcpdump"|grep -v "grep"|awk '{print $2}'` sudo kill -9 $x
I ran cap.sh
sudo ./cap.sh
so in fact in this shell I can run sudo without a password and the host is just a virtual fragment on the remote machine (PLanetlab node) although I see the tcpdump process from ps -ef it doesnโt ps -ef anything I see that mypcap is 0 bytes after cap.sh completed cap.sh
What are the potential causes? and how to make tcpdump in a shell script capture packets? thanks!
source share