Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Print to stdout and stderr in one run?

I’m currently running some code with a timeout and I’m printing stdout to myOut.out and stderr to myError.out.

isError=""
{
   timeout 5s $program_name < $runTest > myOut.out # stdout file
   timeout 5s $program_name < $runTest >&2 myError.out # stderr file
   # Gets return of process 
   isError=$(echo $?)               
} &> /dev/null

Is there a way to make both files with one timeout?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

By >&2 do you mean 2>? You can put both redirections, > and 2>, on the same command.

timeout 5s $program_name < $runTest > myOut.out 2> myError.out
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading