Thread: Start Apache?

  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Rep Power

    Start Apache?

    is it possible to start apache with python, I tried:
    os.system('sudo /usr/sbin/apachectl start')
    and the code returned is 256

    thanks for any help
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    London, England
    Rep Power
    The default behaviour for sudo is to prompt for your user password before executing the command, which the os.system function cannot handle. You also need to have permission to run the command in the /etc/sudoers file. To see what commands you have permission to execute, type 'sudo -l'.

    To send the password you need to use an interactive session with a tool like [url=]pexpect[url]. Using pexpect you can write a function to send the apachectl command, wait for the "Password:" prompt, then send the password. Alternatively if you have write access to the sudoers file then you can configure it not to prompt for a password, which should get round the need to use pexpect.

    Dave - The Developers' Coach

IMN logo majestic logo threadwatch logo seochat tools logo