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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Richard Quadling wrote:
> 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.
>   
Windows does have isatty() function. Perhaps the functions of the posix
extension which
make sense should be ported.



-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux