Welcome Guest, Not a member yet? Register   Sign In
Script run via Cli fails BUT same script triggerd directly is fine.
#1

[eluser]Unknown[/eluser]
Hi.

I have a script that I run as a cron and via cli.
It works like a dream if i trigger it from a browser but seems to fail if I run it via the cron /cli

The code below seem to stop where I placed this comment

/*XXXXXXXXXX script SEEMS to stop here XXXXXXXXXXXX*/


Code:
function fetch_files(){
  error_reporting(ALL);
  set_time_limit(0);
  ini_set('memory_limit', '512M');

  
  $upl_notices = array();
  // load the amazon S3 lib  
  $this->load->library('aws_s3');
  
                $this->load->library('email');
  
  //define the path for the content folder
  $path = "new_content";
  //$path = "delme";
  
  //using the opendir function
  $dir_handle = opendir($path) or die("Unable to open $path");



  // call the list dir function which returns and array of all of the files in the folder.
  $this->list_dir($dir_handle,$path);
/*XXXXXXXXXX script SEEMS to stop here XXXXXXXXXXXX*/
  print_array($this->files_list);
  $i=0;
  // loop through the files
  foreach($this->files_list as $f){
  
  
   // only upload the file if it is an mp3
   if(substr($f['file'],-3) == "mp3" || substr($f['file'],-3) == "MP3"){
      // presp the upload to the amazon cloud
    
     $this->aws_s3->batch()->create_object('mofilm', 'content/'.$f['file'], array(
             'fileUpload' => $f['path'],
             'acl' => AmazonS3::ACL_PUBLIC,
             'headers' => array( // raw headers
             'Content-Disposition' => 'attachment; filename='.$f['file']
            ),
             )
            );
  
    
     $upl_notices[$i]['debug'][] = 'mp3 file found and added to upload batch '.$f['file'];
  
   }
   elseif(substr($f['file'],-3) == "xls" || substr($f['file'],-4) == "xlsx")
   {
    // email me the xl file
    $this->email->from('[email protected]', 'mofilm');
    $this->email->to('[email protected]');
    
    $this->email->subject('new content xls');
    $this->email->message('New content xls attached.');
    $this->email->attach($f['path']);
    
    $this->email->send();
    $this->email->clear();
    
    //echo $this->email->print_debugger();
    $upl_notices[$i]['debug'][] = 'excel file emailed to you';
    
    
   }
   else
   {
    $upl_notices[$i]['debug'][] = 'no action taken file not valid type';
    
   }

   //echo "<br>".$f['file']."_".$i;
   $i++;
  }




Theme © iAndrew 2016 - Forum software by © MyBB