"Hanson, Rob" <[EMAIL PROTECTED]> writes:
> I'm not sure, probably by forking and execing. It won't return the result
> code from the other program though.
>
>
> $some_process = 'tcpdump -v -ieth0 >file';
>
> my $pid = fork();
> unless ($pid) {
> exec($some_process);
> die "Can't start $some_process: $!";
> }
>
> print "Pid is $pid\n";
>
For some reason the pid printed does not match the output of ps:
actual sample script"
---
#!/usr/local/bin/perl -w
my $cmd = 'tcpdump -v -ttt -i rl0 -w ';
my $fpath = "/var/log/dump";
my $base_fname = "dump_all";
my ($afname);
$afname = "$fpath" . "/" . "$base_fname";
my $pid = fork();
unless ($pid) {
exec("$cmd $afname &");
die "Can't start $cmd: $!";
}
print "Pid is $pid\n";
---
Script output:
# dump_all.pl
Pid is 15173
[fwobsd:root] /root
# tcpdump: listening on rl0
ps wwaux|grep tcpdump
root 30335 0.0 1.6 1116 1048 p0 S 6:03PM 0:00.02
tcpdump -v -ttt -i rl0 -w /var/log/dump/dump_all (tcpdump-3.4.0-or)
Note the script outputs 15173 and ps shows 30335
Do you have an idea what is happening here?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>