Re: [gentoo-user] directing program output
On January 28, 2004 02:17 pm, Diego Zamboni wrote: > > i run "cvs update > /dev/null" or "cvs update | sed -e > > 's//yyy/'" it still prints the same thing it always does. > > how do i capture this information? > > cvs prints many of its messages to standard error (STDERR) instead of > standard output. In bourne-like shells (including bash), you use 2> > instead of > to redirect stderr (in csh-like shells it's different). See > the bash (or csh) man page for more information. Additionally, Google > found these pages with some information and examples: > > http://tomecat.com/jeffy//shredir.html > http://www.losurs.org/docs/redirection > > In your example, if you wanted to pass both stdout and stderr (this is, > everything cvs prints out) to a command, you could simply do: > > cvs update 2>&1 | sed -e 's//yyy/' > > If you wanted to pass only stderr, it gets more complicated: > > (cvs update > /dev/null) 2>&1 | sed -e 's//yyy/' > > Again: these examples work only in Bourne shell and its derivatives. wow, thanks. just one last question: why does cvs do this? isn't STDOUT the "standard" place to pipe outgoing information? -- problems cannot be solved at the same level of awareness that created them. - albert Einstein -- [EMAIL PROTECTED] mailing list
Re: [gentoo-user] directing program output
> i run "cvs update > /dev/null" or "cvs update | sed -e 's//yyy/'" > it still prints the same thing it always does. how do i capture this > information? cvs prints many of its messages to standard error (STDERR) instead of standard output. In bourne-like shells (including bash), you use 2> instead of > to redirect stderr (in csh-like shells it's different). See the bash (or csh) man page for more information. Additionally, Google found these pages with some information and examples: http://tomecat.com/jeffy//shredir.html http://www.losurs.org/docs/redirection In your example, if you wanted to pass both stdout and stderr (this is, everything cvs prints out) to a command, you could simply do: cvs update 2>&1 | sed -e 's//yyy/' If you wanted to pass only stderr, it gets more complicated: (cvs update > /dev/null) 2>&1 | sed -e 's//yyy/' Again: these examples work only in Bourne shell and its derivatives. --Diego -- [EMAIL PROTECTED] mailing list
Re: [gentoo-user] directing program output
gabriel wrote: when i run a program like "ls" the output is to STDOUT so i can pipe it or redirect it through something like sed or grep. but cvs doesn't do that. if i run "cvs update > /dev/null" or "cvs update | sed -e 's//yyy/'" it still prints the same thing it always does. how do i capture this information? The information is written to standard error instead of standard output. To capture standard error: cvs update 2> /dev/null To capture both: cvs update > /dev/null 2> /dev/null or cvs update > /dev/null 2>&1 -- "Codito ergo sum" Roel Schroeven -- [EMAIL PROTECTED] mailing list
Re: [gentoo-user] directing program output
gabriel wrote: when i run a program like "ls" the output is to STDOUT so i can pipe it or redirect it through something like sed or grep. but cvs doesn't do that. if i run "cvs update > /dev/null" or "cvs update | sed -e 's//yyy/'" it still prints the same thing it always does. how do i capture this information? '>' redirects only STDOUT. If you want to redirect STDERR, you'll need to use '2>'. if you want to suppress all output, you can connect the streams and redirect them to /dev/null: cvs update > /dev/null 2>&1 see man bash for further help. bye, Christoph -- [EMAIL PROTECTED] mailing list