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
print pack("A25",pack("V*",map{1919242272+$_}(34481450,-49737472,6228,0,-285028276,6979,-1380265972)))