XML : running php on ubuntu through shell - unlink & fopen always fail

I am trying to delete an xml file, and then re-create it with data from an xml feed using cURL.

my PHP code is as follows:

  function get_file($file, $local_path, $newfilename){  //Delete old xml file first    unlink('../../xml/file.xml');    // Create a new one  $out = fopen($local_path.$newfilename,"wb");    if ($out == FALSE){      print "<br>File not opened<br>";      exit;  }    $ch = curl_init();    // Setup options, where to write etc  curl_setopt($ch, CURLOPT_FILE, $out);  curl_setopt($ch, CURLOPT_HEADER, 0);  curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);  curl_setopt($ch, CURLOPT_TIMEOUT, 28800);  curl_setopt($ch, CURLOPT_URL, $file);    // Execute  curl_exec($ch);    // Close  curl_close($ch);  }    // get_file(url_of_file, directory_to_put, filename);  get_file('XML FEED URL', '../../xml/', 'file.xml');    

this code used to work fine until I moved to an Ubuntu virtual server. I want to use the code by running the following command:

  php ../var/www/html/php/cron/download_xml_feed.php    

the xml folder (and current xml file) are located at ../var/www/html/xml

Every time I run the command however it gives me:

  PHP Warning:  unlink(../../xml/jobs.xml): No such file or directory in /var/www/html/php/cron/download_xml_feed.php on line 7    PHP Warning:  fopen(../../xml/jobs.xml): failed to open stream: No such file or directory in /var/www/html/php/cron/download_xml_feed.php on line 10    

this will eventually be a crontab run with the above command

How can I get it to work?

No comments:

Post a Comment