Results 1 to 9 of 9
hi all
what is the meaning of this.
2> /dev/null
can u please explain.
thank you in advance...
- 05-18-2007 #1Linux Newbie
- Join Date
- Feb 2007
- Location
- hyderabad, india
- Posts
- 247
Redirecting to dev/null
hi all
what is the meaning of this.
2> /dev/null
can u please explain.
thank you in advance"Relationships are built on trust and communication"
- 05-18-2007 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Have a read of this:
RegardsCode:http://www.tldp.org/LDP/Bash-Beginners-Guide/html/sect_08_02.html#sect_08_02_03
- 05-18-2007 #3Linux Newbie
- Join Date
- Feb 2007
- Location
- hyderabad, india
- Posts
- 247
thank you for quick replay
"Relationships are built on trust and communication"
- 05-18-2007 #4Linux User
- Join Date
- Oct 2004
- Location
- /dev/random
- Posts
- 404
2 is the stderr file descriptor.
The Unforgiven
Registered Linux User #358564
- 05-18-2007 #5Linux Newbie
- Join Date
- Feb 2007
- Location
- hyderabad, india
- Posts
- 247
- 05-18-2007 #6Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
It's mostly used with the system- or popen functions.
On what case do you want to use that in your C program?
Regards
- 05-18-2007 #7Linux Newbie
- Join Date
- Feb 2007
- Location
- hyderabad, india
- Posts
- 247
thank you for quick replay
"Relationships are built on trust and communication"
- 05-18-2007 #8Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
That means that an error message from your program, you write with these functions, goes to /dev/null:
RegardsCode:perror("Error!"); fprintf(stderr, "%s: %s\n", "Error: ", "error message");
- 05-19-2007 #9Linux User
- Join Date
- Oct 2004
- Location
- /dev/random
- Posts
- 404
When a process is started by the kernel, it opens 3 file descriptors by default for every process:
o. 0 -> stdin (mapped to keyboard)
o. 1 -> stdout (mapped to the monitor/console/terminal)
o. 2 -> stderr (mapping same as stdout)
Conventionally, good programming practice says that all the error messages by any program should be output to stderr (i.e. fd = 2) - that's what the standard functions like perror() do.
This is because, if you want to capture only the error messages separately, the stderr file descriptor can be redirected to a file while normal output keeps coming to stdout fd - this way you get more control over how to handle the messages.
If you expect some error messages to be dumped by a program even in normal cases and want to just send them to trash, you use "2> /dev/null" construct.
HTH
The Unforgiven
Registered Linux User #358564


Reply With Quote
