Basher52 wrote:Another thing...the first '>' character u wrote in ur example, this one i know is for putting the output into a file, but the next things:
'2>&1 &' i dont know :(
i think i know that the last '&' means to start the daemon as backgrouns process, right? but what about the '2>&1'
'>' redirects STDOUT
"2>' redirects STDERR
'2>&1' redirects STDERR to STDOUT
'&' starts a process in the background and returns control to the command line
Did you ever run a command and try and pipe it into the "more" (or less) command annoyingly only to find out that "more" seemed to have no effect (page the output)? An example might be to type this:
Since you didn't give xset a parameter it just spit out a help screen. Well, the help screen probably scrolled off of your screen so normally one would pipe it into "more" so you can read what scrolled by one page at a time like so:
Hmmm, "more" didn't seem to work huh? That's because the "xset" command printed it's help page out to the STDERR channel and not STDOUT like most programs do it and more is only readong STDIN. So what you can do is redirect the STDERR channel to STDOUT and then pipe it to more like so:
Now more can page it.
Having two channels like this is very useful because you can send messages (maybe error messages) out the STDERR channel and send normal messages out the STDOUT channel and have them go to two different places. Maybe you want to redirect STDOUT to a file but have any error messages go to your screen:
Or maybe you want normal output to go to one file and errors go to another file:
Code: Select all
somecommand > somefile.log 2> somefile.err
Or maybe you just want both normal messages and error messages to go to the same file:
which is usually what I do when starting commands in the background. If you do not redirect the output when you background a command the command can hang up if it does have to send a message as it no longer has a place to go (if you background it and log off that is). Most good programmers (and some not so good, like me) make good use of both STDOUT and STDERR.