Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Execution KSH Script from Perl

by gaal (Parson)
on Jan 18, 2007 at 20:26 UTC ( [id://595338]=note: print w/replies, xml ) Need Help??


in reply to Execution KSH Script from Perl

When you invoke it on the command line, your shell strips off the quotes. The ksh script doesn't see the "s in the first "FAMP.001.DAT", but does see them the second one precisely because they are quoted. (The same goes to for the other arguments.)

So, in Perl, you don't need to do any special quoting since your invocation doesn't pass through an interactive shell. You don't need to do so much string interpolation inline, either; a clean way of adding the quotes is with a helper function. This should work:

$return_val = system($grph_gen_multi_seq, $data_source_contents[2], myquote($data_source_contents[2]), $seq_num, myquote($seq_num), $data_source_contents[1]); # ... sub myquote { my($str) = @_; return "\"$str\""; }

Replies are listed 'Best First'.
Re^2: Execution KSH Script from Perl
by johngg (Canon) on Jan 18, 2007 at 20:54 UTC
    Rather than writing a subroutine to do the job, you could use Perl's quoting constructs. They also avoid the need to escape the double quotes you are wrapping around the string.

    $ perl -le ' > $seq_num = 1234; > $quoted_seq_num = qq{"$seq_num"}; > print qq{$seq_num - $quoted_seq_num};' 1234 - "1234" $

    The code would become

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

    Cheers,

    JohnGG

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://595338]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2024-04-23 15:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found