Jump to content


Photo

Apache, Php, Python and Expect


  • Please log in to reply
1 reply to this topic

#1 half.italian

half.italian
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 19 October 2006 - 12:22 AM

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

#2 half.italian

half.italian
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 19 October 2006 - 08:30 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users