cesarcesar Posted March 17, 2009 Share Posted March 17, 2009 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 // set pathing $file = 'TEXT_small.m4v'; $localfile = '/user/dac420/incoming/'.$file; $remotefolder = '/user/dac420/outgoing/'; // exec the file and pass vars. transfer.php for this example just echo's Hi to the motherboard. exec('php transfer.php '.$localfile.' '.$remotefolder.' > '.$file.' &', $output, $result); print_r($output); print_r($result); Running this code and few variations of it give me either empty $result and $output vars or this [0] => Status: 404 [1] => Content-type: text/html [2] => X-Powered-By: PHP/4.3.9 [3] => [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. Link to comment https://forums.phpfreaks.com/topic/149805-exec-a-php-file/ Share on other sites More sharing options...
jackpf Posted March 17, 2009 Share Posted March 17, 2009 This might help you out- http://www.phpfreaks.com/forums/index.php/topic,243338.msg1136267.html#msg1136218 Link to comment https://forums.phpfreaks.com/topic/149805-exec-a-php-file/#findComment-786644 Share on other sites More sharing options...
cesarcesar Posted March 17, 2009 Author Share Posted March 17, 2009 @jackpf - thanks for the link. it was good info. I have added the missing /usr/bin/php -f but its still comes back with empty vars. Link to comment https://forums.phpfreaks.com/topic/149805-exec-a-php-file/#findComment-786658 Share on other sites More sharing options...
cesarcesar Posted March 18, 2009 Author Share Posted March 18, 2009 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. Link to comment https://forums.phpfreaks.com/topic/149805-exec-a-php-file/#findComment-787582 Share on other sites More sharing options...
trq Posted March 18, 2009 Share Posted March 18, 2009 Given the data provided your command would end up looking like.... php transfer.php /user/dac420/incoming/TEXT_small.m4v /user/dac420/outgoing/ > TEXT_small.m4v & to your shell. Why are you sending the output of the command to TEXT_small.m4v ? Link to comment https://forums.phpfreaks.com/topic/149805-exec-a-php-file/#findComment-787591 Share on other sites More sharing options...
cesarcesar Posted March 18, 2009 Author Share Posted March 18, 2009 Why are you sending the output of the command to TEXT_small.m4v ? Not sure! Link to comment https://forums.phpfreaks.com/topic/149805-exec-a-php-file/#findComment-787598 Share on other sites More sharing options...
trq Posted March 18, 2009 Share Posted March 18, 2009 Can we see transfer.php ? Link to comment https://forums.phpfreaks.com/topic/149805-exec-a-php-file/#findComment-787637 Share on other sites More sharing options...
cesarcesar Posted March 18, 2009 Author Share Posted March 18, 2009 All it does is accept vars sent in the exec() and uses the values to start the transfer. The page runs fine if called regularly with spoofed vars. Link to comment https://forums.phpfreaks.com/topic/149805-exec-a-php-file/#findComment-787643 Share on other sites More sharing options...
trq Posted March 18, 2009 Share Posted March 18, 2009 How is the transfer done? Does it even need to be a php script at all? Link to comment https://forums.phpfreaks.com/topic/149805-exec-a-php-file/#findComment-787701 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.