in reply to Execution KSH Script from Perl

The shell is eating _some_ of the quote characters. As you're calling the system with multiple args, it's not passing it to your shell, and they're not being removed. Try the following:

$return_val = system($grph_gen_multi_seq, $data_source_contents[2], "\"$data_source_contents[2]\"", $seq_num, "\"$seq_num\"", $data_source_contents[1]);

Replies are listed 'Best First'.
Re^2: Execution KSH Script from Perl
by rheaton (Acolyte) on Jan 18, 2007 at 20:21 UTC

    I have tried that as well. The KSH is responding differently when it is called from the perl script like that and when it is run from the cmd line. Thanks for the thought though.

      That suggests that its environment is a little different (perhaps that it had loaded different startup scripts).

      Maybe your problem isn't with passing the arguments? If you can edit the ksh script, just add a debug dump of what it got and compare.

      It's likely then that you have more than one problem with your script, as the quoting one is blatant. However, you said you've verified the path and the values in the arguments, and I can't think of anything else that it might be, so I'd ask that you check again, using the following methods:

      First, make sure that the command runs from your script, by using backticks, so you can capture any messages:

      my $output = `gen_multi_seq.ksh "FAMP.001.DAT" '"FAMP.001.DAT"' "001" '"001"' "AMP_DFR" &2>1`;

      If it's a problem with pathing, this should hopefully give you a clue.

      Next, check to make sure that the values that the command you're generating is correct:

      warn <<EOF; system($grph_gen_multi_seq, "$data_source_contents[2]", "\'\"$data_sou +rce_contents[2]\"\'", "$seq_num", "\'\"$seq_num\"\'", "$data_source_c +ontents[1]"); EOF;

      If either of these two are the problem, and you correct them, I really do believe that the quoting issues with then be shown to be a problem, and you'll need to correct them as well.