Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^3: Trying to get an external c program to print to a file

by bart (Canon)
on Nov 04, 2011 at 12:18 UTC ( #935908=note: print w/replies, xml ) Need Help??


in reply to Re^2: Trying to get an external c program to print to a file
in thread Trying to get an external c program to print to a file

I mean that
system("$PGMEXEC1", "-arg1=$arg1", "-arg2=$arg2", ">${workingDir}${ps +}$outputFile1");
will not work, you have to use something like
system("$PGMEXEC1 -arg1=$arg1 -arg2=$arg2 >${workingDir}${ps}$outputFi +le1");
See system for the difference between the two.

If your variable arguments can contain spaces or other characters that are special for the shell, you'll have to escape them. If on Linux or another Unix-derivative, you can use the module String::ShellQuote to handle the hard work. If on Windows, just putting double quotes around the arguments should do, unless you're making life really hard on yourself. (You can wrap the whole command line in qq so you don't have to escape the quotes. Oh, you can't use single quotes there because the variables need to be replaced by their values.)

Replies are listed 'Best First'.
Re^4: Trying to get an external c program to print to a file
by JavaFan (Canon) on Nov 04, 2011 at 12:43 UTC
    But you can write:
    system "'$PGMEXEC1' '-arg1=$arg1' '-arg2=$arg2' > '${workingDir}${ps}$ +outputFile1'";
    Which works fine, unless any of the variables contains a single quote, or ends in a backslash.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (2)
As of 2018-12-16 05:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many stories does it take before you've heard them all?







    Results (70 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!