Page 1 of 1

exec and shell_exec

Posted: Thu Nov 16, 2006 7:56 am
by urieilam
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.
From looking around the internet, I came up with this code to run it:

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

Try passthru()

Posted: Thu Nov 16, 2006 8:49 am
by zeek
Try using passthru() instead of exec() for now, as it will pass you the raw output from the command line, so you can troubleshoot. There are many potention reasons for it 'not working', with permissions at the top of the list. You will most likely need to change the the permissions, group, or owner of ffmpeg.

You should research the most secure solution to this, as I don't know the answer. I found this link (http://onlamp.com/pub/a/php/2003/02/06/ ... tions.html), it is a good start.

Hope this helps.

UPDATE: Actually you want Part 2 of that tutorial, sorry (http://www.onlamp.com/pub/a/php/2003/04 ... urity.html)

Posted: Sat Nov 18, 2006 12:11 pm
by urieilam
ftp_exec also isn't working. i'm guessing then that i'm having security issues, maybe php permissions. any thoughts?

Posted: Sat Nov 18, 2006 12:18 pm
by feyd
You have two separate threads dealing with two separate things. Don't try to mix them, please.

Posted: Sun Nov 19, 2006 1:12 am
by dibyendrah
Before going too deep, try to execute simple things like

Code: Select all

print shell_exec("ls -lth");
print exec("whoami");
etc etc...

If they works and then you have to do next steps like checking the file ownership, command parameters you are passing. Before going to next step, just try to execute that program like

Code: Select all

exec("/usr/local/bin/ffmpeg")
If this works then you have problem in parameters or ownership.

Hope these steps will help you.

Cheers,
Dibyendra