View previous topic :: View next topic |
Author |
Message |
gentoo_0x00 n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/79809063142cb0411c1849.gif)
Joined: 10 Mar 2005 Posts: 21 Location: Portland, Oregon
|
Posted: Mon May 30, 2005 10:09 pm Post subject: Expect passwd script not working as expected [Solved] |
|
|
I am trying to get this most basic expect script working for password changes.
Code: | #!/usr/bin/expect
spawn passwd [lindex $argv 0]
set password [lindex $argv 1]
expect "password:"
send "$password\r"
expect "password:"
send "$password\r"
expect eof
|
When I run it I get this
Code: |
# ./changePass j12 1tp4hbK
spawn passwd j12
New UNIX password: 1tp4hbK
Retype new UNIX password:
|
Then it just seems to timeout... No password changed.
I cant seem to find anyone else who has had this problem, which leads me to believe I am just doing something stupid. I have wrote other expect scripts that automate ssh logins, never a problem. I think something is messed up with the sending data to passwd. Also would not on a redhat box.
I would use chpasswd but it uses a different encryption type and I want all ecryption types the same.
Anyone please help me... Does this code work on your system? _________________ What if there was no such thing as hypothetical questions?
Last edited by gentoo_0x00 on Tue May 31, 2005 12:48 am; edited 1 time in total |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
gentoo_0x00 n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/79809063142cb0411c1849.gif)
Joined: 10 Mar 2005 Posts: 21 Location: Portland, Oregon
|
Posted: Tue May 31, 2005 12:48 am Post subject: |
|
|
The problem is expect is just too darn fast... It needs to slowed down by adding a sleep command.
Code: | #!/usr/bin/expect
spawn passwd [lindex $argv 0]
set password [lindex $argv 1]
expect "password:"
sleep 0.1
send "$password\r"
expect "password:"
sleep 0.1
send "$password\r"
expect eof
|
_________________ What if there was no such thing as hypothetical questions? |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|