Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^2: Detecting interactive/non-interactive shell

by TheDamian (Priest)
on Jul 06, 2005 at 20:51 UTC ( #472934=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download

  1. or download this
        if (-t STDIN && -t STDOUT) {
            print "Enter an integer: ";
  2. or download this
        my $count = <>;
  3. or download this
    sub is_interactive {
        return -t *ARGV && -t *STDOUT;
    if (is_interactive()) {
        print $PROMPT;
  4. or download this
    -t *ARGV
  5. or download this
    sub is_interactive {
        # Not interactive if output is not to terminal...
    if (is_interactive()) {
        print $PROMPT;
  6. or download this
    use IO::Interactive qw( is_interactive );
    if (is_interactive()) {
        print $PROMPT;
  7. or download this
    use IO::Interactive qw( interactive );
    # and later...
    print {interactive} $PROMPT;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://472934]
[LanX]: ... well like always :)
[zentara]: LanX One day, I will see a great interest in Tk. It's small, self-contained, needs very few external libraries, AND makes it easy to make high-contrast displays. :-)
[zentara]: Corion in this cased they left the www. out
[zentara]: /d// :-)
[LanX]: i like tk, just joking. but what about modern styles?
LanX has to run. .. o/
[zentara]: modern styles are secondary to display readability. Tk is automatically good at the clunky industrial theme. :-)

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2017-05-26 12:40 GMT
Find Nodes?
    Voting Booth?