By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,953 Members | 1,505 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,953 IT Pros & Developers. It's quick & easy.

exec() a php file

P: 162
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/';
  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);
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.
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.
Mar 17 '09 #1
Share this Question
Share on Google+
4 Replies

Expert 100+
P: 1,168
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.
Mar 17 '09 #2

P: 162
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.
Mar 18 '09 #3

Expert 100+
P: 1,168
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.
Mar 18 '09 #4

P: 162
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);
Mar 18 '09 #5

Post your reply

Sign in to post your reply or Sign up for a free account.