Harry Putnam wrote: > > "John W. Krahn" <[EMAIL PROTECTED]> writes: > > > open FILE, '>file' or die "Cannot open file: $!"; > > my $pid = open DUMP, 'tcpdump -v -ieth0 |' or die "Cannot open pipe from > > tcpdump: $!"; > > print FILE while <DUMP>; > > close DUMP or die "Cannot close pipe from tcpdump: $!"; > > close FILE; > > > > print "Pid was $pid\n"; > > Looking at this, I'm guessing one doesn't get to know the pid until > its all over. (I can't try it out right now). Which in this case > would not be usefull.
You can print the PID before the loop starts: open FILE, '>file' or die "Cannot open file: $!"; my $pid = open DUMP, 'tcpdump -v -ieth0 |' or die "Cannot open pipe from tcpdump: $!"; print "Pid is $pid\n"; print FILE while <DUMP>; close DUMP or die "Cannot close pipe from tcpdump: $!"; close FILE; > This thing needs to run until at the 4hr mark syslog sends a SIGHUP > and rotates the ouput files. All that is taken care of by syslog. > > But the tcpdump process runs continuously. Only stopped by outside > forces and then restarted. > > There is probably some standard way to put those pid numbers in > /var/run but I don't know it. use File::Basename; my $pid_file = '/var/run/' . basename( $0 ) . '.pid'; { open my $PID, '>', $pid_file and print $PID "$pid\n" }; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>