in reply to Can a script tell if it is being run from inside a script versus in an interactive terminal session?

You might try seeking on STDIN. If its connected to a redirected file, it should succeed; if its a pipe it will fail:

C:\test>perl -E"seek STDIN, 0,0 or die $!" <junk.txt C:\test>echo junk.txt | perl -E"seek STDIN, 0,0 or die $!" Invalid seek at -e line 1.

Put the seek in a die block and check for the error condition.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re: Can a script tell if it is being run from inside a script versus in an interactive terminal session?
  • Download Code