in reply to How do I Determine if my script is being piped to?
I am not answering your question because I wonder if you are asking the wrong question.
In your first case you need to learn to intervene gracefully.
You script is waiting for end of input, so tell it there is no more input.
In a UNIX shell ctrl-D indicates end of file.
|
|---|