Msg for Chris & Unix/Linux gurus

Posted by on July 4, 2006

Chris, I know you read this so maybe you have a suggestion…

I have a KSH script file which is called from a 3rd party app. Sometimes the script file is called with data “piped” to it. I cannot control how the script gets called.

In my script file, I have a line that reads:

cat >> $TMPF

If data is piped, that command dumps the piped data to a file located in the TMPF variable. However, if there is no data in the pipe, CRASH. cat is looking for info from STDIN which is the keyboard, and since this script runs in background, it hangs the app.

Do you know of a way to detect if data is in a pipe? If I knew whether or not there was data in the pipe, I could build a condition to prevent the whole problem.

Any ideas?

Leave a Reply