in reply to Running a C program from Perl
The backticks around the command-line string tell perl to capture whatever output is produced on the command's stdout, but since the command includes a redirection of stdout to a file, there will be nothing available for perl to assign to your "$result" variable -- it will get an empty string, because all the stdout content from "hello.txt" is written (via redirection) to the "output.txt" file.$result = `$bin > output.txt`;
I get the impression that this isn't what you intended. If you want $result to store the (numeric) exit status of the command, use system; if you want it to get the stdout content from the command, remove the > output.txt part from the command line string.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Running a C program from Perl
by n4nature (Novice) on May 26, 2009 at 05:36 UTC | |
by Utilitarian (Vicar) on May 26, 2009 at 07:20 UTC | |
|
Re^2: Running a C program from Perl
by Bloodnok (Vicar) on May 26, 2009 at 16:06 UTC | |
by graff (Chancellor) on May 27, 2009 at 02:16 UTC | |
by Bloodnok (Vicar) on May 27, 2009 at 09:31 UTC | |
by ikegami (Patriarch) on May 27, 2009 at 13:45 UTC |