SPUG: exec question
Tim Maher
tim at consultix-inc.com
Fri Feb 11 09:36:46 PST 2005
On Fri, Feb 11, 2005 at 09:23:16AM -0800, Dan Ebert wrote:
> I have a script which manages a bunch of other scripts. Basically it
> kicks off a specific script depending on the situation it sees when it
> runs.
>
> I want it to kick off the script then exit without waiting around for the
> other script to finish. I thought this would do it:
>
> # code to decide what script to use
> exec($script);
> but the manager script doesn't exit when it does the exec. Any ideas?
> Thanks,
>
> Dan.
If $script contains the name of a file with a proper shebang line,
and you're on UNIX or Linux, and $PATH is set to the directory $script
is in or $script contains the pathname directory itself, then
something like this might be what you're after:
system "nohup $script > /tmp/output.$$ 2>&1 &" ;
That command runs $script in the background (so the parent won't
wait for it to complete), with STDOUT and STDERR redirected to
a unique filename.
-Tim
*--------------------------------------------------------------------------*
| Tim Maher, PhD (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX |
| tim(AT)Consultix-Inc.Com http://TeachMePerl.Com http://TeachMeUnix.Com |
*+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*
| Watch for my upcoming book: "Minimal Perl for UNIX/Linux People" |
*--------------------------------------------------------------------------*
More information about the spug-list
mailing list