note 42194 added to function.posix-isatty

From: Date: Fri, 07 May 2004 06:12:21 +0000
Subject: note 42194 added to function.posix-isatty
Groups: php.notes 
Request: Send a blank email to php-notes+get-69296@lists.php.net to get a copy of this message
Can be useful to determine whether output is being piped elsewhere, for PHP shell scripts, for example; #!/usr/local/bin/php <?php if ( !posix_isatty(STDOUT) ) { fwrite(STDOUT, "Invalid TTY\n"); exit(2); } fwrite(STDOUT, "Enter you name\n"); $name = fgets(STDIN); fwrite(STDOUT,"Hello $name\n"); exit(0); ?> If this script is like: script.php > outfile outfile will contain "Invalid TTY" ---- Manual Page -- http://www.php.net/manual/en/function.posix-isatty.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42194 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42194&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42194&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#69296) next »