Question

I am writing some testing scripts and want to catch all error output and write it to an error log as well as all regular output and write that to a separate log. I am using a command of the form

cmd > output.file 2> error.file

The command I am writing test scripts for can cause a segmentation fault. When the command segfaults, bash still prints out segmentation fault to the terminal.

I want this to not happen or get redirected along with standard error.

Is it possible? It must be of bash's doing because both output streams are being redirected.

Was it helpful?

Solution

bash -c 'cmd >output.file 2>error.file' >bash_output.file 2>&1

OTHER TIPS

I don't think segfaults are part of your program's output from the shell's point of view. So use

Expect for more reliable output

http://en.wikipedia.org/wiki/Expect

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top