Page 1 of 1

shell_exec problem

Posted: Sun Aug 12, 2007 12:02 pm
by ZicoBarton
Hi all,
not sure if this is the correct place to post this question but here goes.

I am trying (and failing) to execute a command line program with the php function shell_exec.

Some commands work, dir for example is fine and shows me all the files in that directory.

I have image magic installed on the server which, when run from a command prompt via remote desktop connection, works fine.
But when I run the same command using the shell_exec function it doesn't work. I don't get an error or anything, the output file just isn't created.

I really want to get ffmpeg running, but when i try to use this progam via shell_exec I get a "502 - Bad Gateway" error.

Again, the same command using remote desktop connection it works fine.

The server is running Windows 2003 server, and I dont know if its a PHP problem (maybe a config problem) or a server problem (permissions perhaps?).

If anyone has any ideas I'd appreciate a reply.
Thanks
Zico

Posted: Sun Aug 12, 2007 12:29 pm
by feyd
sounds more like a permissions problem.

Posted: Sun Aug 12, 2007 2:36 pm
by ZicoBarton
Thanks for the quick reply.

I have tried setting the permissions on the executable (ffmpeg.exe) but I wasn't sure which user to give access to it.
As a test I have the user group 'Everyone' full access, but this hasn't worked.

Do you know who I should give access to, what level of access I should give them and what do I give them access too (ie the executable only, or the entire directory)?

Thanks
Zico

Posted: Sun Aug 12, 2007 2:46 pm
by timvw
Is it possible that ffmpg is trying to interact with the desktop? (As a network service does not and should not allow that)

Posted: Mon Aug 13, 2007 11:09 am
by ZicoBarton
I don't think so no.
When I run it from a command prompt on the server no windows are loaded for either ffmpeg or image magic.
Although that's not to say it inst loading a 'hidden' window?

Posted: Thu Aug 16, 2007 6:28 am
by ZicoBarton
There havnt been any replies for a couple of days now so I am assuming no one has an easy answer?

Does anyone know what permissions I should set to run a shell_exec command?
e.g. Full Access, Read Only etc.
Also what user do I allow access?

Should I set the permissions on the exe I am trying to run, the entire directory or cmd.exe?

Thanks again for your help.

Posted: Thu Aug 16, 2007 8:52 am
by stereofrog
Try running your command with 2>&1, perhaps you get a meaningful error message.

As for permissions, IIRC on windows you have to go to Start - Settings - Services (or similar), double-click Apache service and select your own account on the "login" tab (assuming this is your local test server and security is not a concern).