[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

backtick commands and stderr

Alexandru Popescu

10/26/2006 11:23:00 PM

Hi!

When executing a system op using the backtick method, the standard
output is caught and returned in the assigned variable:

output= `ls -Al`

I am wondering what happens with the standard error output? I have
written a script that executes well in the happy path scenario, but
for the case where the invoked system tool is writting to stderr I
have no idea how to trap that.

Any help and ideas are highly appreciated,

/alex
--
w( the_mindstorm )p.

3 Answers

Wilson Bilkovich

10/26/2006 11:35:00 PM

0

On 10/26/06, Alexandru Popescu <the.mindstorm.mailinglist@gmail.com> wrote:
> Hi!
>
> When executing a system op using the backtick method, the standard
> output is caught and returned in the assigned variable:
>
> output= `ls -Al`
>
> I am wondering what happens with the standard error output? I have
> written a script that executes well in the happy path scenario, but
> for the case where the invoked system tool is writting to stderr I
> have no idea how to trap that.
>
> Any help and ideas are highly appreciated,

Since it's a system command, you can ask it to redirect stderr to stdout:

output = `ls -Al 2>&1`

Alexandru Popescu

10/26/2006 11:42:00 PM

0

On 10/27/06, Wilson Bilkovich <wilsonb@gmail.com> wrote:
> On 10/26/06, Alexandru Popescu <the.mindstorm.mailinglist@gmail.com> wrote:
> > Hi!
> >
> > When executing a system op using the backtick method, the standard
> > output is caught and returned in the assigned variable:
> >
> > output= `ls -Al`
> >
> > I am wondering what happens with the standard error output? I have
> > written a script that executes well in the happy path scenario, but
> > for the case where the invoked system tool is writting to stderr I
> > have no idea how to trap that.
> >
> > Any help and ideas are highly appreciated,
>
> Since it's a system command, you can ask it to redirect stderr to stdout:
>
> output = `ls -Al 2>&1`
>

That was it! Great!

/alex
--
w( the_mindstorm )p.

>

Ara.T.Howard

10/27/2006 3:52:00 AM

0