Possible Duplicate:
How to call shell script from php that requires SUDO?
I have a Python file that needs SU rights to run (on Ubuntu server).
Can't figure out how to do it.
Running it from PHP like so:
$command = "python /path/to/my/file.py params";
$temp = exec($command, $output);
var_dump($output);
Not working. (Xvfb fails to start for non-root)
Tried:
$command = "echo 'root_pwd' | sudo -S python /program.py params"
...
didn't work.
Tried: edit /etc/sudoers:
Cmnd_Alias BUNDLE = /path/to/myprog.py
nobody ALL=(ALL) NOPASSWD:BUNDLE
and then:
$command = "sudo -u nobody python myprog.py params";
...
didn't work.
When I say "didn't work" - I mean that var_dump($output) returns empty array, no successful result on server (myprog.py should generate a file on the server) or the page simply loads for a couple mins until it times out.
Basic .py files (that don't require special rights) work.
Pls help.
PS: .Py file is making screenshot of URL, so is using webkitgtk, Xvfb and couple other things.