how do i redirect stderr to a file?
This is what I want to do: I have some cgi scripts and I want to debug them by redirecting the standard error to a file.
I know this much: the cgi script is a child process of apache, and each time it runs, apache hands it several enviornment variables (HTTP_HOST, etc), do I have to change the enviornment it runs in or what? Apache can obviously redirect stdout to a socket, so Im sure I can similarly redirect stderr to a file |
In what language are your scripts written ?
|
theyre written in c. I know I could just use a errorlog file but some of the libraries Im linking in use stderr so its cleaner in my opinion to just spit everything out to stderr
|
You can add sth like this at the beginning of your code:
Code:
#include <fcntl.h> This is not very robust though if there is a very high load on your cgi (risk of mixed output from concurrent executions). |
thanks for that. I guess that dup2 command duplicates the stderr stream and places the result in file
|
The error output stream is in fact redirected, not duplicated, as the previous stderr output is closed during the call.
|
All times are GMT -5. The time now is 01:27 PM. |