SPUG: exec question

Ben Reser ben at reser.org
Fri Feb 11 10:10:15 PST 2005


On Fri, Feb 11, 2005 at 09:36:46AM -0800, Tim Maher wrote:
> 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.  

Ugh that's just ugly.  And runs a shell in the process.  Surely that's
not what he really wants.  From what it sounds like exec is what he
wants, I'm not sure why it's not working right.  Perhaps he's
misunderstanding what it does.  But someone else in the thread already
mentioned it.

Anyway, from a security standpoint, don't ever do stuff like what Tim
showed you above.  If you're passing arguments, then you have to worry
about those arguments having shell meta characters in them...

-- 
Ben Reser <ben at reser.org>
http://ben.reser.org

"Conscience is the inner voice which warns us somebody may be looking."
- H.L. Mencken


More information about the spug-list mailing list