in reply to Re^4: system function adds spurious characters to log file
in thread system function adds spurious characters to log file
I hope you're still following this thread, because I just realized a better way: Test STDOUT, not STDIN. You don't care where the input is coming from, but whether you are outputting to the screen or to a file.
$ cat works.sh #!/bin/sh perl -le 'print "Screen" if -t STDOUT' perl -le 'print "File" unless -t STDOUT' $ sh works.sh Screen $ sh works.sh > out.txt $ cat out.txt File
|
|---|