Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

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

-t 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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 19:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found