em bv I justed tested the if -t and it doesn't work, I got the messages in my log file here is the code a I used with a comment added
# perl -le'print "\e]0;$ENV{HOST}\7" if -t'
| [reply] [d/l] |
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)))
| [reply] [d/l] [select] |
$ cat test.sh
#!/bin/sh
perl -le 'print "Interactive" if -t'
perl -le 'print "Batch" unless -t'
$ sh test.sh
Interactive
$ sh test.sh </dev/null
Batch
print pack("A25",pack("V*",map{1919242272+$_}(34481450,-49737472,6228,0,-285028276,6979,-1380265972)))
| [reply] [d/l] [select] |
okay, if I'm logged in, the PerlMonks bar is red or red-ish otherwise it's blue
| [reply] |