while 1 {
puts "Quit to quit."
send_user "Name of user: "
expect_user -re "(.*)\n" {
set name $expect_out(1,string)
if {[regexp "(Q|q)uit" $name]} {
exit
}
}
send_user "$name password: "
expect_user -re "(.*)\n" {
set pass $expect_out(1,string)
}
password $pass
}
There are good scripts at the expect site (nist), and
the basic idea here is that the proc expect patterns to match are tunable by you....
Use the command exp_internal 1 in this script to debug it,
for your version of passwd. Sometimes the patterns do not match and expect keeps on looking, so you need to watch the debugger to see what is happening.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.