01-15-2009
Alright, so here is how error redirection works..
As you know, to send the STDOUT to /dev/null you do something like this: somecmd > /dev/null
So, to send STDERR to the same place, you can do:
somecmd 2> /dev/null
To send both STDOUT and STDERR to /dev/null you can do:
somecmd > /dev/null 2>&1
the 2 is writing to the same place that 1 is (which is dev null).. The &1 means "Whatever 1 is writing to".
Hopefully that explains it a bit better.
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Maybe it's an stupid question but remeber... I'm Junior..
I use command line to run programs, and some of them gives a lot of information when, for example, you open a window or other actions. That's really bad because my terminal gets full of unwanted messages, so I use "bin file & >/dev/null"... (1 Reply)
Discussion started by: piltrafa
1 Replies
2. Shell Programming and Scripting
Working in a bash environment, in the following example, how do I direct the error message that putting in an invalid flag (-j for example) would normally produce to dev/null?
while getopts "abcd" opt
do
case "$opt" in
i) a etc ;;
r) b etc ;;
f) c etc ;;
v) d... (7 Replies)
Discussion started by: Sniper Pixie
7 Replies
3. UNIX for Dummies Questions & Answers
Is it possible to redirect errors at the command line when you run the script such as bash scriptname & 2>/dev/null? (1 Reply)
Discussion started by: knc9233
1 Replies
4. Solaris
Hi, Anyone can help
My solaris 8 system has the following
/dev/null , /dev/tty and /dev/console
All permission are lrwxrwxrwx
Can this be change to a non-world write ??
any impact ?? (12 Replies)
Discussion started by: civic2005
12 Replies
5. Shell Programming and Scripting
Hi expert,
May I know what is the difference between below cron tab entry ?
0,12 * * * * /abc/myscript.sh > /dev/null 2>&1
0,12 * * * * /abc/myscript.sh (7 Replies)
Discussion started by: olaris
7 Replies
6. UNIX for Dummies Questions & Answers
How are these two different? They both prevent output and error from being displayed. I don't see the use of the "&"
echo "hello" > /dev/null 2>&1
echo "hello" > /dev/null 2>1 (3 Replies)
Discussion started by: glev2005
3 Replies
7. Shell Programming and Scripting
I apologize if this question has been answered else where or is too elementary.
I ran across a KSH script (long unimportant story) that does this:
if ; then
CAS_SRC_LOG="/var/log/cas_src.log 2>&1"
else
CAS_SRC_LOG="/dev/null 2>&1"
fithen does this:
/usr/bin/echo "heartbeat:... (5 Replies)
Discussion started by: jbmorrisonjr
5 Replies
8. Shell Programming and Scripting
I'm using an text-to-speech synthesis in a script, and I need to redirect it's output to /dev/null
how can I do that ? And how to redirect the stream to his normal output then (sound card ) ?
thankx (2 Replies)
Discussion started by: firelink
2 Replies
9. Shell Programming and Scripting
Hello All and a Happy New year to yous guys.
I'm running the below command on my AIX box and it keeps giving me the message that the file doesn't exist. I know the file don't exist, but I don't want to see the error. 2>/dev/null doesn't work.
bash-3.00$ ls -l C* | wc -l 2>/dev/null
ls:... (2 Replies)
Discussion started by: bbbngowc
2 Replies
10. UNIX for Dummies Questions & Answers
Hello.
When I run a .ksh that contains the command below, and there is no file available in the source location the "FILE_NAME_*.CSV not found" error is still being displayed.
FILEN=$(ssh ${SOURCE_SERV} "cd ${SOURCE_LOCATION} ;ls ${FILES}") 2> /dev/null.
This is interfering with the rest... (4 Replies)
Discussion started by: jimbojames
4 Replies
null(n) null(n)
__________________________________________________________________________________________________________________________________________________
NAME
null - Create and manipulate null channels
SYNOPSIS
package require Tcl
package require memchan
null
_________________________________________________________________
DESCRIPTION
The command described here is only available in a not-yet released version of the package. Use the CVS to get the sources.
null creates a null channel which absorbs everything written into it. Reading from it is not possible, or rather will always return zero
bytes. These channels are essentially Tcl-specific variants of the null device for unixoid operating systems (/dev/null). Transfer-
ing the generated channel between interpreters is possible but does not make much sense.
OPTIONS
Memory channels created by null provide one additional option to set or query.
-delay ?milliseconds?
A null channel is always writable and readable. This means that all fileevent-handlers will fire continuously. To avoid starvation
of other event sources the events raised by this channel type have a configurable delay. This option is set in milliseconds and
defaults to 5.
A null channel is always writable and never readable. This means that a writable fileevent-handler will fire continuously and a readable
fileevent-handler never at all. The exception to the latter is only the destruction of the channel which will cause the delivery of an eof
event to a readable handler.
SEE ALSO
fifo, fifo2, memchan, random, zero
KEYWORDS
channel, i/o, in-memory channel, null
COPYRIGHT
Copyright (c) 1996-2003 Andreas Kupries <andreas_kupries@users.sourceforge.net>
Memory channels 2.2 null(n)