in reply to Re^4: Checking for STDIN
in thread Checking for STDIN

You seem to confuse the meaning of STDIN. In "filter" mode, STDIN won't be the terminal, e.g. echo 'foo' | ./test.pl

Replies are listed 'Best First'.
Re^6: Checking for STDIN
by dbmathis (Scribe) on Jul 30, 2008 at 02:37 UTC
    I am sorry but the method you specified does not work for what i am trying to do in cron.

    Please refer to: http://www.unix.com.ua/orelly/perl/cookbook/ch15_03.htm

    The -t operator tells whether the filehandle or file is a tty device. Such devices are signs of interactive use. This only tells you whether your program has been redirected. Running your program from the shell and redirecting STDIN and STDOUT makes the -t version of I_am_interactive return false. Called from cron, I_am_interactive also returns false.

    The POSIX test tells you whether your program has exclusive control over its tty. A program whose input and output has been redirected still can control its tty if it wants to, so the POSIX version of I_am_interactive returns true. A program run from cron has no tty, so I_am_interactive returns false.