I have an
expect script which performs an SSH to a list of servers with the credentials mentioned in the script. It is not throwing any error when it is unable to SSH to a particular server and continues with the next server in the list. I want the script to let me know when it is unable to SSH with the password given. What changes should be made to the script to get this done?
The first script is a shell script which calls the expect script
#!/usr/bin/ksh for host_name in `cat list` do /home/user1/ssh_script $host_name done #!/usr/local/bin/expect -f set timeout 1 set host_name [lindex $argv 0] spawn ssh -q -o StrictHostKeyChecking=no "user1\@$host_name" expect "*assword:" send "abcd@123\r"; expect "$\r" puts "user1 loggedin successfully" exit interact