Connecting Tech Pros Worldwide Forums | Help | Site Map

exec() a php file

Familiar Sight
 
Join Date: Apr 2006
Posts: 133
#1: Mar 17 '09
I'm trying to call a PHP page to run when called from another page. To do this it seems i have to use the exec() function. The code would go something like
Expand|Select|Wrap|Line Numbers
  1. // set pathing
  2. $file = 'TEXT_small.m4v';
  3. $localfile = '/user/dac420/incoming/'.$file;
  4. $remotefolder = '/user/dac420/outgoing/';
  5.  
  6. // exec the file and pass vars. transfer.php for this example just echo's Hi to the motherboard.
  7. exec('php transfer.php '.$localfile.' '.$remotefolder.' > '.$file.' &', $output, $result);
  8. print_r($output);
  9. print_r($result);
  10.  
Running this code and few variations of it give me either empty $result and $output vars or this
Expand|Select|Wrap|Line Numbers
  1.     [0] => Status: 404
  2.     [1] => Content-type: text/html
  3.     [2] => X-Powered-By: PHP/4.3.9
  4.     [3] => 
  5.     [4] => No input file specified.
  6.  
I have Googled "php exec" (and others) but I have come up with few reference. If someone can shed some light on this function or tell me where im wrong in my code i would appreciate it. Thanks.

TheServant's Avatar
Expert
 
Join Date: Feb 2008
Location: Australia
Posts: 914
#2: Mar 18 '09

re: exec() a php file


I think you want to use include() instead... This will include (or execute through your server) a php file where ever it is called in your code.
Familiar Sight
 
Join Date: Apr 2006
Posts: 133
#3: Mar 18 '09

re: exec() a php file


Include/Require will not work. I should have explained better. The page im calling via exec() is transferring 1G file between two servers. If this file is include()'d, the page will hang white until the transfer is complete. Therefor i need to create a separate php process to run in the background. This way once the transfer is started, the user can continue with their browsing without waiting.

The way to do this is with exec(). I just need to know how i went wrong. I think its pathing. Fu*^ing pathing every time! But maybe someone can help. Thanks.
TheServant's Avatar
Expert
 
Join Date: Feb 2008
Location: Australia
Posts: 914
#4: Mar 18 '09

re: exec() a php file


Quote:

Originally Posted by empiresolutions View Post

Include/Require will not work. I should have explained better. The page im calling via exec() is transferring 1G file between two servers. If this file is include()'d, the page will hang white until the transfer is complete. Therefor i need to create a separate php process to run in the background. This way once the transfer is started, the user can continue with their browsing without waiting.

The way to do this is with exec(). I just need to know how i went wrong. I think its pathing. Fu*^ing pathing every time! But maybe someone can help. Thanks.

Apologies, I meant no disrespect. Will look into this more as I have never come across it, but could very well in the near future.
Familiar Sight
 
Join Date: Apr 2006
Posts: 133
#5: Mar 18 '09

re: exec() a php file


Quote:
Apologies, I meant no disrespect.
None taken. Its seems i need the code to look like this, but its still doesn't work.
Expand|Select|Wrap|Line Numbers
  1. exec('/usr/bin/php -f /wv/cpd/html/tsse/tts/demoondemand/v4/temp_transfer.php arg1 arg2 > /dev/null &', $output, $result);
Reply