exec() a php file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • empiresolutions
    New Member
    • Apr 2006
    • 162

    exec() a php file

    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
    Code:
    // 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
    Code:
        [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.
  • TheServant
    Recognized Expert Top Contributor
    • Feb 2008
    • 1168

    #2
    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.

    Comment

    • empiresolutions
      New Member
      • Apr 2006
      • 162

      #3
      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.

      Comment

      • TheServant
        Recognized Expert Top Contributor
        • Feb 2008
        • 1168

        #4
        Originally posted by empiresolutions
        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.

        Comment

        • empiresolutions
          New Member
          • Apr 2006
          • 162

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

          Comment

          Working...