Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Checking for STDIN

by AltBlue (Chaplain)
on Jul 30, 2008 at 01:31 UTC ( [id://700977]=note: print w/replies, xml ) Need Help??

in reply to Checking for STDIN


Replies are listed 'Best First'.
Re^2: Checking for STDIN
by Anonymous Monk on Jul 30, 2008 at 01:35 UTC
    -t will not work because I am using my script in a cron job sometimes.

      What do you mean?!

      Save this code to a file and test it.

      #!/usr/bin/perl -wl use strict; open my $fh, '>', '/tmp/test.log' or die $!; print $fh 'STDIN ', ( -t STDIN ? 'IS' : 'is NOT' ), ' available' or di +e $!; close $fh or die $!;
        In a cron job -t would evaluate to false which in my case would mean my script would think info is being piped to it when I have a commandline option -logfile <file> being used to specify input.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://700977]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-06-15 09:53 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.