in reply to How to get the process Id

This is more a shell question than a Perl question. The usual approach is to get a process which echoes its PID and then have that process replace itself with the target program, keeping the same PID.

Shell scripts can do this using the following idiom:

#!/usr/bin/ksh echo $$ exec tcpdump -i any -w filename.pcap

This will print the PID to the console, but you could just as well output it to a file.