in reply to (tye)Re: Detecting running from cron?
in thread Detecting running from cron?

-t STDIN is definitely very useful; it tells you whether the script is running interactively. But keep in mind that a script can be run from the command line without being run interactively: echo "Hi!" | perl -wle 'print -t() ? "" : "not ", "interactive"' So it might not do what the original poster wants in this case.

Replies are listed 'Best First'.
(tye)Re2: Detecting running from cron?
by tye (Sage) on Jan 23, 2001 at 21:29 UTC

    Thank you. I was relying on the readers to consult the manual on -t (especially since I didn't say whether a true or false value from -t meant "running from cron"). But that was a pretty poor assumption on my part.

    Reading between the lines of the question, I got the impression that the stuff going to STDOUT was meant only to be seen by interactive users, which is why I suggested -t STDOUT. Thinking on it more, I think a better test for this case is -t STDERR so that script <input | more would be considered "interactive" while the cron case specifically stated that STDERR was redirected to a file.

            - tye (but my friends call me "Tye")