Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Expect passwd script not working as expected [Solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
gentoo_0x00
n00b
n00b


Joined: 10 Mar 2005
Posts: 21
Location: Portland, Oregon

PostPosted: Mon May 30, 2005 10:09 pm    Post subject: Expect passwd script not working as expected [Solved] Reply with quote

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
View user's profile Send private message
gentoo_0x00
n00b
n00b


Joined: 10 Mar 2005
Posts: 21
Location: Portland, Oregon

PostPosted: Tue May 31, 2005 12:48 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum