Home > Software design >  Print to stdout and stderr in one run?
Print to stdout and stderr in one run?

Time:12-09

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?

CodePudding user response:

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
  • Related