Redirect stderr to stdout w/ Perl under Unix? 
Author Message
 Redirect stderr to stdout w/ Perl under Unix?

When exec-ing, how can I redirect stderr to stdout so that all output can be
captured into a variable with back ticks?

--

4 Frederick Drive
New Hartford, NY  13413



Mon, 23 Feb 2004 03:14:04 GMT  
 Redirect stderr to stdout w/ Perl under Unix?

Quote:

> When exec-ing, how can I redirect stderr to stdout so that all output can be
> captured into a variable with back ticks?

You can find this in the FAQ, either on your machine

  perldoc -q stderr

or online

  http://www.perldoc.com/perl5.6/pod/perlfaq8.html#How%20can%20I%20capt...

The short answer is, do it just as you would in Bourne shell:

  $output = `$cmd 2>&1`;

I hope this helps,

Tim



Mon, 23 Feb 2004 03:39:34 GMT  
 Redirect stderr to stdout w/ Perl under Unix?


Quote:
> When exec-ing, how can I redirect stderr to stdout so that all output can
be
> captured into a variable with back ticks?

> --

> 4 Frederick Drive
> New Hartford, NY  13413

perldoc -q stderr

"How can I capture STDERR from an external command?"

David Hilsee



Mon, 23 Feb 2004 03:35:57 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Redirect STDOUT from a Unix script to a perl program and then redirect back to script

2. Redirect stderr to stdout inside perl script

3. HELP - with redirect of STDERR and STDOUT

4. redirect STDERR to STDOUT ?????

5. redirecting stderr and stdout

6. writing to terminal even with STDOUT and STDERR redirected

7. assigning STDERR whild redirecting STDOUT to a file

8. Problem with redirecting STDOUT and STDERR

9. How to redirect STDOUT,STDERR and keep the message order

10. Redirecting STDERR to STDOUT (on NT)

11. HELP - with redirect of STDERR and STDOUT

12. need to redirect STDOUT and STDERR

 

 
Powered by phpBB® Forum Software