Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Detecting interactive/non-interactive shell (Perl Cookbook)

by ybiC (Prior)
on Jul 03, 2005 at 20:38 UTC ( #472070=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub I_am_interactive {
      return -t STDIN && -t STDOUT;
    }
    
  2. or download this
    sub I_am_interactive {
      local *TTY; # local file handle
    ...
      close TTY;
      return ($tpgrp == $pgrp);
    }