Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirecting everything in a file created by an executable?

I have a bunch of executable files and I want to store the output of each one of them in a separate file.

For that purpose i am using following command but "2>&1" does not work every time. And sometimes the output files remain empty even though the script does print stuff in shell when run from shell.

What should I use instead of 2>&1?

./$file 2>&1 | tee "$outputFile" 
like image 310
Usman Avatar asked May 19 '26 01:05

Usman


1 Answers

Some executables don't just write to stdout and stderr, but instead open /dev/tty and write to that.

So to redirect those it is necessary to do more complicated procedures involving a psuedo-tty. See the command script, for something that can do this.

like image 197
Darron Avatar answered May 21 '26 14:05

Darron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!