Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problems redirecting from system command

Status
Not open for further replies.

smokinace

Programmer
Jun 12, 2008
18
0
0
US
i am trying to call a system command but can't redirect to a file.
#system ("/home/program", ">", "results/compared.txt");
it thinks the > is a parameter and won't run the program.

another possibility is using backticks
`/home/program > compared.txt`;
but i dont know how to to use variables with backticks.

any help would be appreciated
 
What kind of variables?

Backticks will interpolate variables in the same way that double quotes will.
 
i am trying to put variables directly into the command line for example:

`/home/program -i $gap > compared.txt`;

-i is the parameter with $gap being the number amount. the file is being created but nothing is being put in because of the variable. if a number is used then the program works correctly
 
Then post more code or print $gap right before the system call. Make sure $gap doesn't have a new line in it or anything. backticks does just find with variables. You can also use qx and create your own delimiters (plus I think it's easier to read than backtickets). qx~/home/program -i $gap > /full/path/to/compared.txt~
Please remember to provide full paths to everything.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those who say it cannot be done are usually interrupted by someone else doing it; Give the wrong symptoms, get the wrong solutions;
 
it turns out putting the variable in double quotes inside the backticks treats them as an actual variable. who would have guessed.

thanks for the help :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top