Backtick commands and stderr

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.

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

output = `ls -Al 2>&1`

···

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,

That was it! Great!

./alex

···

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`

--
.w( the_mindstorm )p.

Which shell is ruby using?
Can I control which shell ruby is using?

-Dan

···

On 10/26/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`

--
bikle@bikle.com

man system

(/bin/sh by ISO C/POSIX)

-a

···

On Fri, 27 Oct 2006, Dan Bikle wrote:

Which shell is ruby using?
Can I control which shell ruby is using?

--
my religion is very simple. my religion is kindness. -- the dalai lama