Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Checking for STDIN

by Anonymous Monk
on Jul 30, 2008 at 01:35 UTC ( [id://700979]=note: print w/replies, xml ) Need Help??


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

-t will not work because I am using my script in a cron job sometimes.

Replies are listed 'Best First'.
Re^3: Checking for STDIN
by AltBlue (Chaplain) on Jul 30, 2008 at 02:03 UTC

    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.
        You seem to confuse the meaning of STDIN. In "filter" mode, STDIN won't be the terminal, e.g. echo 'foo' | ./test.pl

Log In?
Username:
Password:

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

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

    No recent polls found

    Notices?
    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.