Welcome Guest, Not a member yet? Register   Sign In
Send errors to stderr instead of stdout
#1

(This post was last modified: 08-14-2024, 09:50 PM by InsiteFX.)

Hi,


Is there a way to send PHP/CI4.5 generated errors to stderr instead of stdout ?

For eg, I have a crontab which sends an email only when it detects content on stderr : 

PHP Code:
*/10 * * * * root php myscript.php > /dev/null 


Here are some examples to illustrate the different scenarii:


PHP Code:
    public function test()
    {
        CLI::write("hello");
    

=> No mail sent => OK because written to stdout



    public function test()
PHP Code:
    {
        CLI::error("An error");
    }    
=> mail sent => OK because written to stderr

    public function test()
PHP Code:
    {
        $t 0;
    
=> no mail sent => Not ok because it generates a DivisionByZeroError to stdout instead of stderr

Thanks for your help,

Fred
Reply
#2

I found this may help but not sure.

Email all cron stdout+stderr output only on stderr
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(08-14-2024, 07:18 AM)Fred9176 Wrote: Is there a way to send PHP/CI4.5 generated errors to stderr instead of stdout ?

Create your custom Exception Handler.
See https://www.codeigniter.com/user_guide/g...n-handlers
Reply
#4

Thanks for your help.

I finally found another wrapper script which fits my needs :
https://stackoverflow.com/questions/4414...-0-in-bash
Reply




Theme © iAndrew 2016 - Forum software by © MyBB