SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Jan 2008
    Location
    Palm Harbor, FL
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Cannot execute a certain program in a PHP script

    For some reason I cannot run the program 'qt-faststart' from a PHP script.
    However, I have no problem running it in the SSH with the same username and in the same directory.
    What might be the problem here?

    PHP Code:
    exec('qt-faststart input.mp4 output.mp4'); 

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2009
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    from the php doc:
    Note: When safe mode is enabled, you can only execute files within the safe_mode_exec_dir. For practical reasons, it is currently not allowed to have .. components in the path to the executable.
    maybe the file is not in the configured safe_mode_exec_dir!?
    Just look into your php.ini and copy the file or place a symbolic link there.
    --------------------------
    Karsten Rieger
    http://www.tritium-design.de

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The user that php runs as(or a group that php user belongs to) will need to be able to execute qt-faststart, and read input.mp4, as well as write to the directory specified by echo getcwd()

    Just to rule path issues out, you might consider specifying absolute pathnames for all 3 files. Might wanna supply the $output and $return_var arguments to see if you get anything useful.

  4. #4
    SitePoint Addict
    Join Date
    Jan 2008
    Location
    Palm Harbor, FL
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    maybe the file is not in the configured safe_mode_exec_dir!?
    Just look into your php.ini and copy the file or place a symbolic link there.
    'safe_mode' is off and 'safe_mode_exec_dir' has no value.


    The user that php runs as(or a group that php user belongs to) will need to be able to execute qt-faststart, and read input.mp4, as well as write to the directory specified by echo getcwd()
    Both, the input and output directories, are also used successfully by ffmpeg.

    I even tried putting the input file in the main directory, and writing the output there as well. No success.

    I'm not too familiar with returning the output of command lines in PHP, but I did try specifying the $output variable for exec(), which returns an empty array. The system() and passthru() functions also return nothing.

    I also get the same empty result from all three functions if no input or output files are specified. In the SSH, this would return the following line:
    Code:
    Usage: qt-faststart <infile.mov> <outfile.mov>

  5. #5
    SitePoint Addict
    Join Date
    Jan 2008
    Location
    Palm Harbor, FL
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I created a valid MP4 file (without the progressive download fix) and a test script and put them in the main folder.

    My test script looks exactly like this:


    PHP Code:
    <?php

    $command 
    escapeshellcmd('qt-faststart input.mp4 output.mp4');

    exec($command,$output,$return_value);

    echo(
    $command.'<br /><br />');

    print_r(array_values($output));

    echo(
    '<br /><br />'.$return_value);

    ?>
    And the output of this script:

    Code:
    qt-faststart input.mp4 output.mp4
    
    Array ( )
    
    127
    Not sure yet what that 127 means; I'm guessing "fail" because 'output.mp4' was not created.

    However, executing the same line of code in the SSH (same username/directory) results in a successful 'output.mp4'.

  6. #6
    SitePoint Addict
    Join Date
    Jan 2008
    Location
    Palm Harbor, FL
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, I seem to have fixed the problem. Thanks for all the advice; I think it was helpful in figuring that out.


    To anyone who experiences a similar problem:

    'qt-faststart' was located in '/usr/local/bin'. PHP is only configured to access '/usr/bin' and '/bin' for external programs.

    I simply logged into the SSH as root and copied qt-faststart from '/usr/local/bin' to '/usr/bin'.

    Now I can successfully execute qt-faststart in my scripts.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •