# check if a password is valid # this is just a subroutine, not a program proc {user password} { spawn su - $user /bin/yes set timeout -1 expect "Password: " send "$password\r" expect { "Sorry" {return 1} eof {return 0} } }