Bash - redirecting stdoutput and stderror does not catch all output

I am writing several test scripts and want to catch all error output and write it to the error log, as well as all regular output and write it to a separate log. I use the form command

cmd> output.file 2> error.file

The command I'm writing test scripts with can cause a segmentation error. When the segfaults command, bash still prints a segmentation error on the terminal.

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

Is it possible? It must be bash because both output streams are redirected.

+4
source share
2 answers
bash -c 'cmd >output.file 2>error.file' >bash_output.file 2>&1 
+11
source

I do not think that segfaults are part of your shell-specific program. Therefore use

Expect for more reliable output.

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

0
source

Source: https://habr.com/ru/post/1286151/


All Articles