Click to See Complete Forum and Search --> : Bash: redirecting all output to /dev/null
Lord_Override
09-09-2001, 08:26 AM
i have a program that works but displays some error messages. i want to make it start during startup so i made a bash script to do it and redirected the output to /dev/null like this /path/to/program &> /dev/null but some error messages are still displayed, probably because they are printing the erros to stderr, is there a way to use a bash script to redirect all of the output to /dev/null?
thanks
Salmon
09-09-2001, 09:10 AM
I believe the '2&1>' construct will do that:
/path/to/program 2&1> /dev/null
Lord_Override
09-09-2001, 10:02 AM
i don't know why but that didn't work, even with standard output and standard error redirected, the error messages are still displayed. unfortunatly this program is not open source either so I can't modify it to print errors elsewhere. is there a way to redirect all output to /dev/null temporarily?
Lord_Override
09-09-2001, 06:41 PM
after a lot of trying and reading many pages that i found on google and linuxdoc, i still can't get it to work, is the only way going to be to go through lots of numbers to find the file descriptor of the stream for the output? that'd be very difficult as the program actually requires me to restart before i can rerun it properly again (it initializes a hardware device).
so, since this seems to not be working are there any other tricks or things that can be used to just not see the output of a command without having access to the source of it?
thank you
Gnu/Vince
09-09-2001, 06:47 PM
/path/to/program >& /dev/null
Nameless
09-09-2001, 07:35 PM
I remeber this senerio at www.hackerslab.org (http://www.hackerslab.org) where we had to send the ourput error messages to /dev/null. I'm pretty sure you have to pipe it
(ie errormessage | /dev/null)
pinoy
09-09-2001, 09:40 PM
How about:
/path/to/program > /dev/null 2>&1
Strike
09-09-2001, 10:19 PM
pipes do one thing:
redirect STDOUT of the thing on the left to the STDIN of the thing on the right ... if the thing on the left or right is not a program, that is not kosher because only programs can open file descriptors (such as STDIN and STDOUT)
The Kooman
09-10-2001, 12:57 AM
Originally posted by Lord_Override:
<STRONG>after a lot of trying and reading many pages that i found on google and linuxdoc, i still can't get it to work, is the only way going to be to go through lots of numbers to find the file descriptor of the stream for the output? that'd be very difficult as the program actually requires me to restart before i can rerun it properly again (it initializes a hardware device).
so, since this seems to not be working are there any other tricks or things that can be used to just not see the output of a command without having access to the source of it?
thank you</STRONG>
Run strace on the application and check out the file descriptor being used when printing the rogue error message that refuses to get redirected. Is the application writing directly to /dev/console?!! Strace will tell you whether its writing to the stdout (or stderr) in the first place, or to some other file descriptor.