Jump to content

exec and shell_exec


urieilam

Recommended Posts

Hello,

I'm new to running exec commands on php.
I've had ffmpeg installed on my server, at /usr/local/bin/ffmpeg  (a cmd line video decoder). It's a linux server, running php5.
From looking around the internet, I came up with this code to run it:

<?php
shell_exec("/usr/local/bin/ffmpeg  -i /home/urieilam/www/work/video/subbed.mov -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 /home/urieilam/www/work/video/test.fla");
?>

It's not working, no error message.
I'm running the code from within /home/urieilam/www/work/video/, is that the mistake? Do I have to add some code to move back to the root directory? If so, what is it?
I've also tried "exec" instead of "shell_exec", hasn't worked either.

Unfortunately, I don't have direct Shell/SSH access, so placing the php code in the root would be a problem (i think).

Anyone know about this stuff? The documentation I've been able to find is pretty lacking.

Thanks
Uri
Link to comment
https://forums.phpfreaks.com/topic/27459-exec-and-shell_exec/
Share on other sites

From looking at the [url=http://uk2.php.net/manual/en/function.shell-exec.php]shell_exec[/url] page at php.net, I'd suggest a few things.

Firstly, echo your command's ouput, that might give you some indication of what's happening.

[code]
$output = shell_exec("/usr/local/bin/ffmpeg  -i /home/urieilam/www/work/video/subbed.mov -ab 56 -ar 22050 -b 500 -r 15 -s 320x240 /home/urieilam/www/work/video/test.fla");
echo(nl2br($output));
[/code]

Secondly, make sure that you're not in PHP safe mode, as shell_exec won't work in that case.

Thirdly, I'd try something simple like an 'ls -l', just to make sure the shell_exec command is working.

Also, does to the webserver user account have permissions to execute ffmpeg?  I don't have a Linux box up at the minute so I can't check the default and if you don't have shell access I don't know if you can either, but it might be something to consider.

Sorry I can't be any more help. :)
Link to comment
https://forums.phpfreaks.com/topic/27459-exec-and-shell_exec/#findComment-125655
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.