pass string to a os prompt

Bart Nessux bart_nessux at hotmail.com
Fri Feb 20 13:42:22 EST 2004


I'm writing a script that does some basic pre-configuration for our new 
Macs (OSX 10.3.2). I'm trying to enable the root account automatically 
with the script, but I don't know how to pass stings to the shell when 
it stops and awaits input. For example,

os.popen('/usr/bin/sudo passwd root')

Cause the OS to respond with:

Password:

How do I pass my current user's password to the prompt? I know that I 
need to store the password in a string in the script, but I don't know 
how to feed it to the waiting shell.

P.S. I know this isn't safe. The script is for config purposes only and 
will be used by sys-support personnel who know the root passwords 
already. This script just *greatly* automates deployment and helps to 
standardise how systems are configured in a lagre environment.

Thanks!




More information about the Python-list mailing list