Re: [Hampshire] Re: Xwindows

Top Page

Reply to this message
Author: Peter Salisbury
Date:  
To: Hampshire LUG Discussion List
Subject: Re: [Hampshire] Re: Xwindows
On Monday 11 Feb 2008, Owain Clarke wrote:
8<
> how do I
> capture the output of the script if I need to paste it? If I do
>
> bash -x /etc/rc2.d/S99gdm start > lugpost
>
> then the file 'lugpost' just contains
>
> Starting GNOME Display Manager: gdm


That's because there are two streams of output, number 1 (stdout)
which is for normal output and number 2 (stderr) which is for error
messages etc. If you use 1> or just > then that redirects stdout to
the file. To put stderr into a file you have to redirect stream 2.
Here is an illustration, the second version, with 2>, shows an error
message being directed into a file:

$ bash -x asdf >out
bash: asdf: No such file or directory
$ cat out
$ bash -x asdf 2>out
$ cat out
bash: asdf: No such file or directory
$

HTH, Peter