Jump to content


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


Apache, Php, Python and Expect

Recommended Posts

I've tried a couple of Python forums with this question, but the more I think about it, the more I think has something to do with the apache environment.

I'm basically trying to have a php page pass one string variable and execute a command on the server using that variable.  I found php system() and exec() and am using system().  The command is executed.  So far so good.  Inside the script (which is python) I use expect to become root, and execute several commands.  Here's the glitch.  If I run the python script from the command line, as 'www' (the user my apache runs as) it becomes root as it should and executes the commands sucessfully.  But, If I have a php script execute the exact same python script, expect does not accept the password, and the commands fail.

I've come to realize that there is something in the apache environment that is not allowing 'www' to become root.  Any ideas on what is going on, or even ideas on how to debug??  I'm at a loss.  Thanks in advance.

~Sean D

Share this post

Link to post
Share on other sites
Just to close the loop: On some advice, instead of using expect, I added an entry to /etc/sudoers so the script could run itself as root.  Problem solved. 

Don''t know why I didn't thin of that.

Share this post

Link to post
Share on other sites


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.