fopen warning

How can I solve these fopen warning.

anton@linux-nfs:~> /usr/bin/php /home/anton/brender/brender_client.php W001 
connected to server 192.168.178.18:3306 : brenderPHP Notice:  Undefined index: computer_name in /home/anton/brender/functions.php on line 418
PHP Notice:  Undefined index: os in /home/anton/brender/functions.php on line 430
PHP Warning:  fopen(logs/.log): failed to open stream: No such file or directory in /home/anton/brender/functions.php on line 437
PHP Warning:  fwrite() expects parameter 1 to be resource, boolean given in /home/anton/brender/functions.php on line 438
PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in /home/anton/brender/functions.php on line 439
PHP Warning:  fopen(logs/brender.log): failed to open stream: No such file or directory in /home/anton/brender/functions.php on line 441
PHP Warning:  fwrite() expects parameter 1 to be resource, boolean given in /home/anton/brender/functions.php on line 442
PHP Warning:  fclose() expects parameter 1 to be resource, boolean given in /home/anton/brender/functions.php on line 443


Permission and path are good.
Is apache looking for absolute path maybe?
Should I set something in php.ini ?

Without all the code this is hard to tell. Use

vardump(VARS_HERE);

, and php will tell you what’s wrong.

EDIT: you may need

/logs/.log

instead of

logs/.log

If I start the script this way its working fine no fopen warning.
But I want to autostart it when booting the workstation (opensuse 12.3 LXDE)

anton@linux-nfs:~/brender> php brender_client.php W001 
connected to server 192.168.178.18:3306 : brenderPHP Notice:  Undefined index: computer_name in /home/anton/brender/functions.php on line 418
PHP Notice:  Undefined index: os in /home/anton/brender/functions.php on line 430
2013/10/12 16:17:58 : info : 

   ---- brender client 0.5 ----
 _                        _           
| |__  _ __ ___ _ __   __| | ___ _ __ 
| '_ \| '__/ _ \ '_ \ / _` |/ _ \ '__|
| |_) | | |  __/ | | | (_| |  __/ |   
|_.__/|_|  \___|_| |_|\__,_|\___|_|   

   ---- brender client 0.5 ----
   

### INFO W001 status : 
2013/10/12 16:17:58 : info : computer name = W001 os = linux
2013/10/12 16:17:58 : info : process id=5752


Sorry I do not understand what you meant with vardump(VARS_HERE);

vardump is a php function. When you run a php script it will output the content of one or more variables.

On topic: Since it does run from it’s own directory, it’s missing a(n absolute) path statement. This could either be to the php-stuff’s root (~/brender/) or the absolute path. Best store that in some config file as a var, then use it.

You could easily write a shell script that changes directory to ~/brender, then executes the php command. Then make the script executable and place it in ~/.config/autostart

Thanks I did make already a shell script.

#!/bin/sh
#This is my brender client startup script

#Un-comment these to add debug
#set -x
#set -v
/usr/bin/php /home/anton/brender/brender_client.php W001 &
echo "Brender script start"    
        
exit 0    


Should I place the logs directory to /var/log.

The changes will make it work in other user’s homedirs too.
I wouldn’t. IMHO ~/brender/logs is the place.

Yes now the line is working many thanks.

greetings
Anton