Results 1 to 8 of 8

Thread: fopen warning

  1. #1
    Join Date
    Jun 2008
    Location
    netherlands
    Posts
    584

    Default fopen warning

    How can I solve these fopen warning.
    Code:
    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 ?

  2. #2
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    19,996
    Blog Entries
    14

    Default Re: fopen warning

    Without all the code this is hard to tell. Use
    Code:
    vardump(VARS_HERE);
    , and php will tell you what's wrong.

    EDIT: you may need
    Code:
    /logs/.log
    instead of
    Code:
    logs/.log
    Last edited by Knurpht; 10-Dec-2013 at 07:47.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  3. #3
    Join Date
    Jun 2008
    Location
    netherlands
    Posts
    584

    Default Re: fopen warning

    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)

    Code:
    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);

  4. #4
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    19,996
    Blog Entries
    14

    Default Re: fopen warning

    Quote Originally Posted by anton View Post
    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)

    Code:
    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.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  5. #5
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    19,996
    Blog Entries
    14

    Default Re: fopen warning

    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
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  6. #6
    Join Date
    Jun 2008
    Location
    netherlands
    Posts
    584

    Default Re: fopen warning

    Thanks I did make already a shell script.
    Code:
    #!/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.

  7. #7
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    19,996
    Blog Entries
    14

    Default Re: fopen warning

    Quote Originally Posted by anton View Post
    Thanks I did make already a shell script.
    Code:
    #!/bin/sh
    #This is my brender client startup script
    
    #Un-comment these to add debug
    #set -x
    #set -v
    cd ~/brender
    /usr/bin/php 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.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  8. #8
    Join Date
    Jun 2008
    Location
    netherlands
    Posts
    584

    Default Re: fopen warning

    Yes now the line is working many thanks.

    greetings
    Anton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •