News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Brian Moon's Blog:
Check for a TTY or interactive terminal in PHP
September 02, 2011 @ 09:12:47

In a new post to his blog Brian Moon describes a need he had for detecting if the client or user calling a PHP script was using an interactive terminal (TTY) or not:

Let's say I am trying to find out why some file import did not happen. Running the job that is supposed to do it may yield an error. Maybe it was a file permission issue or something. There are other people watching the alerts. What they don't know is that I am running the code and looking at these errors in real time.

Since the errors were being sent to the log file, they were lost to the client/user on the other end left staring at their script wondering what went wrong. He ended up with a solution (a pretty simple one too) that uses posix_ttyname and posix_isatty. He includes the little snippet of code he puts in his prepend file that checks for errors then checks for a TTY. If both are there, it turns off logging the errors to the file and sends them direct instead.

0 comments voice your opinion now!
check tty interactive terminal posixisatty posixttyname error log


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: Zend Framework Hidden Gems: Introduction

Chris Jones' Blog: PECL OCI8 1.4.4 is Available

php|architect: Bing Powered 404 for non-WordPress websites

Vidyut Luther\'s Blog: Difference between \"require()\" and \"include()\" in PHP

DevShed: Expanding an Error Logger with the Chain of Responsibility Pattern


Community Events

Don't see your event here?
Let us know!


interview api laravel podcast laravel5 unittest introduction development series feature wordpress framework opinion community voicesoftheelephpant language extension threedevsandamaybe library release

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework