I have an application that runs the a command as below:
<command> <switches> >& /dev/null
I can configure <command>
, but I have no control over <switches>
. All the output generated by this command goes to /dev/null
. I want the output to be visible on screen or redirected to a log file.
I tried to use freopen()
and related functions to reopen /dev/null
to another file, but could not get it working.
Do you have any other ideas? Is this possible at all?
Thanks for your time.
PS: I am working on Linux.
Terrible Hack:
use a text editor in binary mode open the app, find '/dev/null/' and replace it with a string of the same length
e.g '~/tmp/log'
Since you can modify the command you run you can use a simple shell script as a wrapper to redirect the output to a file.
#!/bin/bash
"$@" >> logfile
If you save this in your path as capture_output.sh then you can add capture_output.sh to the start of your command to append the output of your program to logfile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With