I am triggering a UNIX command in Perl script.
I need the process ID of the UNIX command.
For example if i trigger below UNIX command:
# padv
You could use open()
Open returns nonzero on success, the undefined value otherwise. If the open involved a pipe, the return value happens to be the pid of the subprocess.
my $pid = open(my $ph, "-|", "padv -s adv.cfg > adv.out") or die $!;
reading output from $ph
file handle instead of output redirect:
my $pid = open(my $ph, "-|", "padv -s adv.cfg") or die $!;
Call fork to create a child process. The process ID of the child process is returned to the parent process. The child process can then call exec to execute the program you want.