Can PHP determine if the STDOUT for a CLI script is being redirected?

From: Date: Wed, 22 Apr 2009 10:38:32 +0000
Subject: Can PHP determine if the STDOUT for a CLI script is being redirected?
Groups: php.windows 
Request: Send a blank email to php-windows+get-29275@lists.php.net to get a copy of this message
Hi. Is there a simple way for a CLI based PHP script to determine if its output is being redirected to a file or piped through a filter (find, sort, etc.) I'm using ANSI escape sequences to colour the output (all working very nicely), but I want to suppress the codes if the output is being filtered or redirected to a file. I've been told about the posix_isatty() function, but as Windows is not POSIX, I'm looking for a windows mechanism. I've tried stream_get_meta_data(STDOUT), but it doesn't provide anything different when used with > or with |. Any other ideas? Regards, Richard Quadling. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!"

« previous php.windows (#29275) next »