LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   captumring output from STDERR (https://www.linuxquestions.org/questions/programming-9/captumring-output-from-stderr-140365/)

rajatgarg 01-30-2004 10:21 AM

captumring output from STDERR
 
Hi Everybody,

Well I am writing a perl script and I execute a command. I would like to capture the error messages :

Let,

@ar = `ifconfig`;

One way is :

@ar = `ifconfig 2>&1`;
this directs error to console STDOUT and thus can be captured by the handle.

Can u seggest me another method to achieve the same.

Regards,
Rajat Garg

druuna 01-30-2004 10:24 AM

If you want to catch error messages only:

ifconfig 2>>/path/to/some/file

The >> might be accessive, a single > should work.

moses 01-30-2004 10:35 AM

Is there a reason you don't want to use the normal redirect (2>&1)?

Quote:

ifconfig 2>>/path/to/some/file
This just appends STDERR to a file. rajatgarg would then have to open up said file and read from it--very expensive compared with 2>&1.


All times are GMT -5. The time now is 10:31 AM.