Redirect perror to file

Dec 3, 2012 at 12:53pm
Hi,

I want to redirect the output of perror to a file. What is the best way to do that?
Dec 3, 2012 at 1:06pm
It writes to stderr. To redirect stderr to a file from a Bourne Shell derivative:
prog 2> errors.out
Dec 4, 2012 at 5:50am
You mean I can use this statement in a C++ program?
Dec 4, 2012 at 6:09am
wouldn't you want to do something like this?

1
2
// Redirect it
freopen("error.out","w",stderr);


the main problem with this is that you can't 're-redirect' the stream back to the command line
Dec 4, 2012 at 6:37am
You're asking the wrong question.

Use strerror to write the text to a buffer, then you do what you like with it.
Dec 4, 2012 at 8:27am
interesting discussion ... i have no any idea...
Topic archived. No new replies allowed.