Redirecting output of command inside backticks

T

TechCrazy

I am using

`bash_script.sh` inside a perl_script.

How do I redirect the output and error output of command1 to *whatever*
is the stdout and stderr of the perl_script.

The perl_script can be called from commandline like

$ ./perl_script

or

$ ./perl_script > perl_script.out 2>&1

Thanks a lot.
 
T

TechCrazy

I meant

How do I redirect the output and error output of bash_script.sh to
*whatever* is the stdout and stderr of the perl_script.
 
X

xhoster

TechCrazy said:
I am using

`bash_script.sh` inside a perl_script.

How do I redirect the output and error output of command1 to *whatever*
is the stdout and stderr of the perl_script.

By using system rather than backticks.

Xho
 
T

TechCrazy

Thanks a lot Xho. That worked.

I also found this:

-------------------------
http://omaha.pm.org/emails/2003/msg00256.html

Question:
How can I capture STDERR from an external command?

There are three basic ways of running external commands:



system $cmd; # using system()
$output = `$cmd`; # using backticks (``)
open (PIPE, "cmd |"); # using open()


With system(), both STDOUT and STDERR will go the same place as the
script's versions of these, unless the command redirects them.
Backticks and open() read only the STDOUT of your command.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top