in reply to Calling exec on exec

Skip the shell script and pull the java args into your script.pl ...
$ENV{JAVA_STUFF} = "things"; exec(@cmds, @args, @etc);

Although, I must be missing something, because it really aught to work like you expect. The only thing I can think is that you're showing us exec(@cmds), but you're really calling exec("@cmds"); (I could easily be missing something else.)

-Paul

Replies are listed 'Best First'.
Re^2: Calling exec on exec
by shamu (Acolyte) on Sep 19, 2008 at 20:02 UTC

    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.

      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 '"'?