Posted to tcl by schelte at Sat Aug 25 20:07:33 GMT 2012view pretty
#!/usr/bin/expect set file iplist.txt set cmd "ssh-copy-id -i /home/karthick/.ssh/karthick.pub" set user root set password Password123 set f [open iplist.txt] set hostlist [split [read $f] \n] close $f foreach host $hostlist { if {$host eq ""} continue spawn {*}$cmd $user@$host expect { -ex "Are you sure you want to continue connecting (yes/no)? " { send -- "yes\r" exp_continue } -ex "assword: " { send "$password\r" exp_continue } -ex "Permission denied" { puts stdout "Permission denied for $user on following server $host" set f [open login_issue.log a] puts $f "Permission denied for $user on the server $host" close $f } eof {} } }