Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP & creating/writing files across a network

Options
  • 27-09-2002 3:50pm
    #1
    Registered Users Posts: 14,148 ✭✭✭✭


    Hey Guys,

    I have a logging script here, and I'm trying to get it to write to a windows 2k box across the network, but am having difficulties. It [the script] doesn't seem to be getting beyond the linux box
    function updateLog($filename, $code)
    {
            $fileUpdate = 'blah' ;
    
            if(file_exists($filename))
            {
                    if(!($fPtr = fopen($filename, "a+")))
                            echo "I/O Error! Unable to open file\n" ;
    
                    if(($res = fwrite($fPtr, $fileUpdate)) == -1)
                            echo "I/O Error! Write failed\n" ;
    
                    if(!fclose($fPtr))
                            echo "Error! File not closed.\n" ;
            }
            else
            {
                    if($fPtr = fopen($filename, "w"))
                    {
                            if(($res = (fwrite($fPtr, $fileUpdate))) == -1)
                                    echo "I/O Error! Write failed\n" ;
    
                            if(!fclose($fPtr))
                                    echo "Error! File not closed.\n" ;
                    }
                    else
                            echo "I/O Error! Unable to create file\n" ;
            }
    }
    
    $gmsCode = 'xxxxx' ;
    updateLog("10.1.0.xxx:G:\\dir1\\dir 2\\dir3\\users.log", $gmsCode) ;
    

    Any ideas?


Comments

  • Closed Accounts Posts: 304 ✭✭Zaltais


    Don't know about PHP, but I know with perl you can do this using the Filesys::SmbClient or Filesys::SmbClientParser which uses a part of the samba toolset - smbclient - which is an FTP like interface to Windows machines on your network with open shares, enabling you to read and write files.

    Have a google for a PHP equivalent....

    Cheers,

    Zaltais


  • Registered Users Posts: 849 ✭✭✭Cr8or




  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    PHP shouldn't need samba-specific code for this, if you can write to the Windows box from the shell you should be able to write from PHP. However, I've never written to Windows from Linux. Lemming, the network request looks wrong to me - shouldn't you be trying to write to a mount? Also, does the webserver user have permission to do this?

    adam


Advertisement