1 2 3 4 | passwd $user << HERE $newpassword $newpassword HERE |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # Invoke as "change_password <user> <newpassword>". package require expect # Define a [proc] that can be re-used in many # applications. proc update_one_password {user newpassword} { spawn passwd $user expect "password: " exp_send $newpassword\n # passwd insists on verifying the change, # so repeat the password. expect "password: " exp_send $newpassword\n } eval update_one_password $argv |
1 2 3 4 5 6 7 | ... set default_password lizard5 set list [exec cat list_of_accounts] foreach account $list { update_one_password $account $default_password puts "Password for '$account' has been reset." } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ... package require Tk frame .account frame .password label .account.label -text Account entry .account.entry -textvariable account label .password.label -text Password # Show only '*', not the real characters of # the entered password. entry .password.entry -textvariable password -show * button .button -text "Update account" -command { update_one_password $account $password } pack .account .password .button -side top pack .account.label .account.entry -side left pack .password.label .password.entry -side left |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |