PHP errors & notices when executing a file from CLI


After installing a PHP script (CPVlab) I am trying to set up a cronjob that executes a PHP script every day. The script is executed like this : php5 /var/www/htdocs/cron-wurfl.php

After testing this line from the command line, I got the following output :(if it needs t

PHP Warning: visualStylesCheckCall(license/license.php): failed to open stream: 
No such file or directory in /var/www/htdocs/lib/ on line 0

PHP Fatal error: visualStylesCheckCall(): Failed opening required 'license/license.php'
(include_path='.:/usr/share/php:/usr/share/pear') in /var/www/htdocs/lib/ on line 0

I was able to reduce these error messages by playing with the permission scheme (adding myself to the www-data group). However, that didn’t solve it all, as now, when I run : php5 /var/www/htdocs/cron-wurfl.php , I get the output below :

PHP Notice:  Undefined index: SERVER_NAME in /var/www/htdocs/lib/ on line 0
PHP Notice:  Undefined index: REQUEST_URI in /var/www/htdocs/lib/ on line 0

Could this still have to do with the permission scheme I am using ? I have myself as the owner of the htdocs directory, while it is also owned by the group of www-data. Myself as well as www-data (the user) are part of this group.

Anyone know how to solve it ?

Thanks, Lex

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

This does not have to do with permissions. The script you are attempting to run was not written to be run from the command line and is relying on environment variables that are passed to it by the web server. Since the scripts are not being run by the web server process these values are not set. I would recommend editing the PHP code itself to hard-code these variables or adapt the script to read them from the command line.