in reply to Re: Calling exec on exec
in thread Calling exec on exec

Yep, that was it. :)

    my @cmd = (qq(
        $SCRIPT -log="$logfile" -level="$LOG_LEVEL" -file="$job"
    ));

I had some problems with the quoted variables, so I enclosed them in a qq(). I may potentially have strange filenames (spaces, etc.), so I should be doing some error checking on the filenames instead of quoting.

Thanks for the help Paul.

Replies are listed 'Best First'.
Re^3: Calling exec on exec
by ikegami (Patriarch) on Sep 19, 2008 at 20:11 UTC

    If you use the multi-argument form of exec

    exec($SCRIPT, qq{-log="$logfile"}, qq{-level="$LOG_LEVEL"}, qq{-file=" +$job"});

    the strings aren't subject to shell processing before being passed to the child (the script), so whatever you put here will be received. For example, the following three statements are equivalent.

    exec('ls "foo bar"') -> shell passes [foo bar] to [ls] exec('ls foo\ bar) -> shell passes [foo bar] to [ls] exec('ls', 'foo bar') -> perl passes [foo bar] to [ls]

    The problem is that you're using a bad syntax for your parameters. What if you have a file name that contains '"'?