Working on a little script the other day I had the need to determine if the input to the script was coming from a pipe or from the terminal. Seems like a simple enough thing to determine but nothing jumped immediately to mind and a quick internet search didn't help much either. After a bit of pondering I came up with two solutions: the stat command and using information from the proc file system.
Alert Manager was created to run a (alert) command, monitor the status of that command's output, and guarantee that if something goes wrong it won't go unnoticed. Alert Manager has been successfully deployed in several fortune 500 companies providing guaranteed alert delivery and command execution. It has a very flexable configuration file that allows creation of "alert chains" - chains of commands, each with their own fallback command, failure command, timeout, retry counter, and other advanced options. It has a method for passing messages from the command line into the various commands defined in the configuration file and many other useful features. Alert Manager is licensed under the GPL.
Logdog is a tool that monitors messages passing through syslogd and takes action based on key words and phrases. Logdog has a configuration file which allows you to specify a list of key words or phrases to alert on, and a list of commands that can be run when those words are encountered. Logdog is licensed under the GPL.
swatch (the “Simple WATCHer”) does. swatch, written 100% in Perl, monitors logs as they're being written to and takes action when it finds something you've told it to look for. This simple, flexible and useful tool is a must-have for any healthily fearful system administrator.