![]() |
|
#1
|
||||
|
||||
Re: Pipes and RedirectionI just posted a GID Community blog entitled: Piping and Redirection.
Quote:
Please let me know what you think. This is an auto-generated message posted by GIDNetwork™ on behalf of the author. Last edited by admin : 22-Aug-2005 at 15:58.
|
|
#2
|
||||
|
||||
|
Stderr Redirection This is a small addition to this excellent piping and redirection tutorial. This is not so much a C/C++ theme as it is a scripting theme. It is also possible to redirect the stderr stream as well as the stdin stream. This could be useful, if you want to create a "log" file of your errors/warnings, but not have them interfere with the "normal" output of your program. Take this small, worthless example of a c code: CPP / C++ / C Code:
If you compile and run this, you will get: Code:
However, if you run this program with a redirection like: Code:
You will get on the console only: Code:
If you run it again with: Code:
This is quite helpful in writing daemon routines. For *nix only, I could make any program a daemon by using: Code:
The ampersand tells *nix to spawn the process in the background and return control to the calling program. This would throw all standard output to the end of the existing /var/log/messages file and throw all of the standard error stuff to a newly created file called mydaemon.log. |
Recent GIDBlog
Gang violence and the drug culture by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The