|
Page 1 of 1 |
|
Posted: Tue, 24th Jun 2008 17:08 Post subject: PHP shell_exec not working correctly... |
|
 |
I doubt im going to get a response since i've never even heard of this problem before and im not too sure how this problem occurred :
As far as i know, the entire script broke when I decided it would be a good idea to recompile PHP (Bad idea!) I then decided to downgrade from PHP 5 to PHP 4.4.7 (Orig version)
and.. nothing!
Code: | <?php
$convert = "ffmpeg -i /home/test/test.mov -ar 22050 -vb 524288 -f mp4 -s 320x240 /home/test/test.mp4";
$download=shell_exec($convert);
?> |
The problem seems to me, is that it will exec a command and the php script will die right away therefore the shell dies - beforehand it would wait until the shell script had completed. Why is it not doing that?
|
|
Back to top |
|
 |
Rinze
Site Admin
Posts: 2343
|
Posted: Tue, 24th Jun 2008 18:09 Post subject: |
|
 |
Any error messages?
Permissions?
Compiled with safe mode?
|
|
Back to top |
|
 |
|
Posted: Tue, 24th Jun 2008 19:09 Post subject: |
|
 |
Rinze wrote: | Any error messages? |
Nope, the code is fine.. its just PHP handling it differently :-/
have not changed since compliing
Quote: | Compiled with safe mode? |
Nope
|
|
Back to top |
|
 |
|
Posted: Tue, 24th Jun 2008 20:11 Post subject: |
|
 |
Breakthough! it seems there is a workaround to shell_exec :
Code: | <?php
function runExternal($cmd,&$code) {
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a file to write to
);
$pipes= array();
$process = proc_open($cmd, $descriptorspec, $pipes);
$output= "";
if (!is_resource($process)) return false;
#close child’s input imidiately
fclose($pipes[0]);
stream_set_blocking($pipes[1],false);
stream_set_blocking($pipes[2],false);
$todo= array($pipes[1],$pipes[2]);
while( true ) {
$read= array();
if( !feof($pipes[1]) ) $read[]= $pipes[1];
if( !feof($pipes[2]) ) $read[]= $pipes[2];
if (!$read) break;
$ready= stream_select($read, $write=NULL, $ex= NULL, 2);
if ($ready === false) {
break; #should never happen - something died
}
foreach ($read as $r) {
$s= fread($r,1024);
$output.= $s;
}
}
fclose($pipes[1]);
fclose($pipes[2]);
$code= proc_close($process);
return $output;
} |
But the problem now is that when you run :
Code: | $result= runExternal("ffmpeg -i /test/test.mov -ar 22050 -vb 524288 -f mp4 -s 320x240 /test/test.mp4",$code);
print " ";
print $result;
//print "\n";
print "code: $code\n"; |
It outputs :
[code]sh: ffmpeg: command not found code: 127[/code]
So i'm not sure what its looking for here, since i dont know enough about the linux file system? any ideas?
See the thing is it runs ffmpeg fine when you type in it in shell, so im kinda confused on this one lol
|
|
Back to top |
|
 |
Rinze
Site Admin
Posts: 2343
|
Posted: Tue, 24th Jun 2008 22:24 Post subject: |
|
 |
Are you running PHP as a different user than before, with different path settings?
Try using the full path to ffmpeg.
|
|
Back to top |
|
 |
|
|
Back to top |
|
 |
Page 1 of 1 |
All times are GMT + 1 Hour |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB 2.0.8 © 2001, 2002 phpBB Group
|
|
 |
|