exec and shell_exec

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
urieilam
Forum Newbie
Posts: 10
Joined: Sat Sep 09, 2006 1:24 pm

exec and shell_exec

Post 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
User avatar
zeek
Forum Commoner
Posts: 48
Joined: Mon Feb 27, 2006 7:41 pm

Try passthru()

Post 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)
urieilam
Forum Newbie
Posts: 10
Joined: Sat Sep 09, 2006 1:24 pm

Post by urieilam »

ftp_exec also isn't working. i'm guessing then that i'm having security issues, maybe php permissions. any thoughts?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You have two separate threads dealing with two separate things. Don't try to mix them, please.
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post 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
Post Reply