in reply to Altering Behavior of a Script

If I were writing a C program on *nix I would use isatty. I have never used it but POSIX provides this function which should work if you are on a POSIX compliant system. For another idea based on stat see http://perl.plover.com/yak/commands-perl/samples/slide016.html.