Victor Reyes
12/27/2007 2:45:00 PM
[Note: parts of this message were removed to make it a legal post.]
Team,
First, thank you for all your suggestions. They are greatly appreciated.
I tried the:
*userCMD_output* *= `#{input} 2>&1`*
But could not capture the error. Matter of facts the error to the *ls *command
was displayed on the screen as:
*ls: 0653-341 The file totot does not exist. *
Second, I tried using the *Open3* method and when I tried to display the
content of stdin, stdout and stderr just to inspect their contents, this is
what's there:
*stdin, stdout, stderr = Open3.popen3(input)*
puts stdin
puts stdout
puts stderr
*#<IO:0x20060638>
#<IO:0x200605fc>
#<IO:0x20060598> *
It looks like I can't get this thing to work.
Thanks a bunch for all the help from everyone.
Victor
On Dec 27, 2007 12:05 AM, Tom Metge <tom@accident-prone.com> wrote:
> just saw that i duplicated a response. sorry.
>
> On Dec 26, 2007, at 9:30 PM, James Gray wrote:
>
> > On Dec 26, 2007, at 9:03 PM, Tim Hunter wrote:
> >
> >> Victor Reyes wrote:
> >>> Hello Team,
> >>> I wrote the simple piece of code below which under "normal"
> >>> circumstances it
> >>> works fine.
> >>> If, however, the command executed generates an error msg, the
> >>> error is
> >>> displayed on the screen.
> >>> This is a behaviour which I don't want.
> >>> I would like to capture ALL output generated by the command and
> >>> return it to
> >>> the caller.
> >>> I tried different tricks but nothing worked. The question is:
> >>> How can I capture ALL output from line: *userCMD_output =
> >>> `#{input}`*
> >>> including stderr???
> >>>
> >>
> >> When you use backticks to capture the output from a command, what
> >> you get is whatever the command writes to stdout. If the command
> >> writes an error message to stderr you can't capture it.
> >
> > Well, you could fold STDERR into STDOUT. In my Unix shell that's
> > done with:
> >
> > `#{cmd} 2>&1`
> >
> > Hope that helps.
> >
> > James Edward Gray II
> >
>
>
>