Next Unix Command Internals 16

But what if you do care?

        @statinfo = stat STDOUT;
        if (    $statinfo[2] & 0020000
            && ($statinfo[6] & 0xff) == 5) { print "Terminal\n" }
        else { print "Not a terminal\n" }
        use POSIX 'isatty';
        if (isatty(STDOUT)) { print "Terminal\n" } 
        else { print "Not a terminal\n" }
        if (-t STDOUT) { print "Terminal\n" } 
        else { print "Not a terminal\n" }


Next Copyright © 2003 M. J. Dominus