SitePoint Sponsor |
|
User Tag List
Results 1 to 6 of 6
Hybrid View
-
Oct 7, 2009, 12:55 #1
- Join Date
- Jan 2008
- Location
- Palm Harbor, FL
- Posts
- 348
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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');
-
Oct 7, 2009, 13:03 #2
- 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.
Just look into your php.ini and copy the file or place a symbolic link there.
-
Oct 7, 2009, 14:38 #3
- 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.
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()
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>
-
Oct 7, 2009, 13:13 #4
- 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.
-
Oct 7, 2009, 22:57 #5
- 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);
?>
Code:qt-faststart input.mp4 output.mp4 Array ( ) 127
However, executing the same line of code in the SSH (same username/directory) results in a successful 'output.mp4'.
-
Oct 7, 2009, 23:30 #6
- 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