EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Capturing stdout/stderr and sending stdin

Posted: 03/10/2012 11:23:06
by Eugene Mayevski (Team)

I am not an expert in Linux so I am having hard time writing something to stderr . I tried running "zip aaa bbb 2>error.txt" (where aaa and bbb don't exist) in console, but error.txt is created empty and the error message is written in console. Then I tried running "ls xxx 2>error.txt" and I got a message saying that xxx not found AND that 2 not found. I guess there must be some other notation.

It would be nice if you also sent the script for the server and also explained how it can be proved that the script wrote to stderr and not stdout
Posted: 03/11/2012 20:35:16
by Andy Gardner (SUPPORT DISABLED)
Joined: 02/17/2012
Posts: 51

Here is a sample script that writes to both stdout and stderr:
echo this goes to stdout
echo this goes to stderr >&2
echo this goes to stdout >&1

I named the script test.sh. At the command line enter the following:
./test.sh >stdout 2>stderr

After the script is run, stdout contains:
this goes to stdout
this goes to stdout

and stderr contains:
this goes to stderr
Posted: 03/12/2012 06:06:23
by Vsevolod Ievgiienko (Team)

Answered in Helpdesk.



Topic viewed 4070 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!