[EMAIL PROTECTED] wrote:
Hi,

I'm trying to get a script that will enter/change a user's password



The 'passwd' command 'blocks'; it does not 'fork'.  Another way
of saying this is that only one 'passwd' command may run at
any one time in a system for obvious reason. A second, third,
etc, will sleep and timeout when the 'passwd', that a process is
waiting on has not completed.


I have the following 'Expect' script:

~_________ doPass ________________________ /
#!/usr/bin/expect -f

# Try inserting here: pidof passwd >/dev/null RETVAL=$? if [ $RETVAL -eq 0 ]; then echo "Try again later, another passwd process is running!" sleep 2 else
set username [lindex $argv 0]
set password [lindex $argv 1]

spawn passwd $username
expect "New password: " send "$password\r"
expect "Retype new password: "
send "$password\r"
send "exit\r"
expect eof
fi
\_________________________________________

This works fine the first time, then times out when running consecutive times.
Does anyone know what is happening and why it times out if I run it twice or 3
times in a row?

any help would be appreciated,

-- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to