Re: Re: Menu on bootup?

Steve Holdoway <[email protected]> Tue, 18 Oct 2011 09:13:41 +1300
Newsgroups gmane.org.user-groups.linux.new-zealand.general
Organization Green Gecko Global Ltd.
Message-ID <1318882421.23346.14.camel@steve-desktop>
On Mon, 2011-10-17 at 20:28 +1300, Bruce Clement wrote:
> On Mon, Oct 17, 2011 at 8:04 PM, Nevyn <[email protected]> wrote:
> 
> >
> > exec </dev/console >/dev/console 2>&1
> > [...]
> >
> 
> 
> > I've never really understood file
> > descriptors. Is anyone able to explain that first line to me?
> >
> 
> "2>&1" = close file descriptor 2 & make it an alias of file descriptor 1
> 
> Which doesn't really help unless you know that 2 is STDERR (Standard Error
> stream) and 1 is STDOUT (Standard Output stream)
> 
> So this just says send error messages to the output stream, not to the
> console (Unless the console happens to be the destination of the output
> stream).
> 
> HTH
> 
Standard streams ( created by default when any process starts ):

0 = input
1 = output
2 = error

The difference between stdout and stderr is that stdout is buffered,
whereas stderr is not - you see error messages immediately.

If you wish to combine the 2 output streams ( eg to save all output to a
file, or to post-process with another command ), you can redirect one to
the other: 2>&1 sends error to out, 1>&2 sends out to error. You can
also send to a file ( &>filename redirects all output as a shortcut ).

Note in the example above that the order of redirection is important:

command >filename 2>&1 

output and error will end up in filename

command 2>&1 >filename

output -> filename
error -> output

Clear as mud???

(:

Steve


-- 
Steve Holdoway BSc(Hons) MNZCS <[email protected]>
http://www.greengecko.co.nz
MSN: [email protected]
Skype: sholdowa

_______________________________________________
NZLUG mailing list [email protected]
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug