# check if a password is valid # this is just a subroutine, not a program proc passwdchk {user password} { package require Expect log_user 0 spawn -noecho su - $user /bin/yes set timeout -1 expect "Password: " send "$password\r" expect "Sorry" {error} } # test it out if {[catch {passwdchk [lindex $argv 0] [lindex $argv 1]}]} { puts "password is bad" } else { puts "password is good" }