SPUG: exec question

DeRykus, Charles E charles.e.derykus at boeing.com
Fri Feb 11 10:24:23 PST 2005


Never mind... I exec'ed a dumb answer. 

It is good form to check for errors BTW but
see Tim's answer.

--
Charles

-----Original Message-----
From: DeRykus, Charles E 
Sent: Friday, February 11, 2005 9:58 AM
To: Dan Ebert
Cc: spug-list at mail.pm.org
Subject: RE: SPUG: exec question


You might check for an error:

exec($script,$config,$file_to_process)
  or warn "exec failed: $!";


--
Charles DeRykus

-----Original Message-----
From: Dan Ebert [mailto:mathin at mathin.com] 
Sent: Friday, February 11, 2005 9:46 AM
Cc: spug-list at mail.pm.org
Subject: Re: SPUG: exec question



Here are some more details ... this is what I have:

$script = '/home/dan/script.pl';
$config = '/home/dan/config.cfg';
$file_to_process = '/path/to/file';

exec($script,$config,$file_to_process);

(The $script expects 2 commandline args, the config file and the file to
process.)

I don't need to capture STDOUT or STDERR (the script executed has logging built in to it).

The solution you suggest will probably work, I'm just curious why exec isn't returning immediately and the script exiting.  I thought that was what exec was supposed to do?

Dan.
----------------------------------------------------------
Immigration is the sincerest form of flattery.
	- Unknown
----------------------------------------------------------


On Fri, 11 Feb 2005, Tim Maher wrote:

> 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"    |
> *---------------------------------------------------------------------
> -----*
>

_____________________________________________________________
Seattle Perl Users Group Mailing List  
     POST TO: spug-list at pm.org
SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
    MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med
    WEB PAGE: http://seattleperl.org/ _____________________________________________________________
Seattle Perl Users Group Mailing List  
     POST TO: spug-list at pm.org
SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
    MEETINGS: 3rd Tuesdays, Location: Amazon.com Pac-Med
    WEB PAGE: http://seattleperl.org/


More information about the spug-list mailing list