in reply to Problem with backtick?
Hi
Sorry I misunderstood your question on my previous post.
From perldoc system:
This is not what you want to use to capture the output from a command, for that you should use merely backticks or qx//, as described in "`STRING`" in perlop.
To read both a command's STDOUT and its STDERR separately, it's easiest to redirect them separately to files, and then read from those files when the program is done:
system("program args 1>program.stdout 2>program.stderr");
Original submission:
Hi
The following code doesn't print anything on the screen:
`echo test`;The following, instead, does:
print `echo test`;
The backticks (man perlop) just spawn a new process, execute the stuff, and capture the output on the left-hand-side variable.
Example:
my $output = `echo 123!`; print $output
Basically, what has happened to your code is that the string got echoed on _another_ process, whose output you never bothered printing.
Hope this helps
|
|---|