Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run .pl or .exe in background

Status
Not open for further replies.

CJason

Programmer
Oct 13, 2004
223
0
0
US
I need to kick off a .pl or .exe from another perl script and have it run in the background...while continuing on with the current script. The only "special" thing I need to do is to give the new process a specific name.

I found Proc::Forking on CPAN...which is REALLY close to what I need. However, that appears to only working on functions and not other scripts/exes.

Any ideas? Thanks in advance!
 
I think I got it...at least good enough for what I need:

Code:
if ($pid = fork) {
  #parent...do stuff here
} elsif (defined ($pid)) {
  if (.exe) {
    $cmd = '/home/me/doit.exe'
    exec $cmd 'HELLO';
  } else {
    $cmd = '/usr/bin/perl';
    exec $cmd 'HELLO','/home/me/doit.pl';
  }
}

running ps -f:
for the .exe, you get 'HELLO'
for the .pl, you get 'HELLO /home/me/doit.pl'

This is good enough for me! Hope this helps someone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top