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

I have a perl script that at the moment has a command line option -logfile <file> where it gets input by reading the <file> into the script. I would like to be able to check to see if stdin is being piped into my file so that I can change the flow of my script and get my input for the pipe instead.

When the -t option is used within a cron job the -t test evalutes to false or in my case it would make my script appear to be having input piped to it when in fact in my cron job I have -logfile <file> specified.

Make sense?

Replies are listed 'Best First'.
Re^3: Checking for STDIN
by ikegami (Patriarch) on Jul 30, 2008 at 02:22 UTC
    Sounds like what you actually want to do is check of -logfile was specified.
      I think you are right. Might be the only way.

        I don't know about it being the only way, but checking if -logfile was provided as an argument is definitely the most direct way of doing something only if -logfile was provided as an argument.

        I don't see what cron or STDIN has to do with anything. Is there some other case you haven't mentioned?

        By the way, I don't see why you don't just pipe it in from cron like you do from the command line.