in reply to Re^2: Running a C program from Perl
in thread Running a C program from Perl
If the command in backticks generates any output on its own stderr, that goes directly to the perl script's STDERR, and does not get captured/assigned by the backticks -- in the OP case, $result will still be empty, because backticks only return what went to the command's stdout.
Now, if the command being run in backticks included redirection of stderr to stdout (and no subsequent redirection of stdout to some file), then backticks would capture any stderr content along with any stdout -- e.g. if your backticks are executing a bourne-style shell, the following would generally include some sort of error message to the perl variable, along with any matching lines found by grep in ~/.bashrc:
my $result = `grep PATH ~/.bashrc /no/such/file 2>&1`
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Running a C program from Perl
by Bloodnok (Vicar) on May 27, 2009 at 09:31 UTC | |
by ikegami (Patriarch) on May 27, 2009 at 13:45 UTC |