set timeout10
# set host 192.168.1.4
set name ubuntu1410
# set password root
set host
set password
set new_password
spawnssh $host -l $name
expect {
"(yes/no)?" {
send "yes\n"
expect "assword:"
send "$pasword\n"
}
"assword:" {
send "$password\n"
}
}
expect "ubuntu1410"
send "uname\n"
expect "Linux"
send_user"Now you can do some operation on this terminal\n"
send"passwd $name\n"
expect "(current) UNIX password:"
send "$password\n"
expect "Enter new UNIX password"
send "$new_password\n"
expect "Retype new UNIX password"
send "$new_password\n"
expect eof刚学习expect,试了一下可以修改user的password。 思路大致差不多。
页:
1
[2]