* Please do not buy or tell me to use SSH keys. If it seems to me that I am doing this, pretend that I'm trying to connect to telnet. :-) *
I use a wait script to run some routine commands on many servers under my control through ssh. The script should run a set of commands (for example, svn update ~ / folderx \ r ") on each of the computers. My current script does everything I want it to do ... sometimes. Sometimes it leaves the ssh connection before it will complete one of the last teams.
Any thoughts on how I can establish a connection until all the commands are complete? The code below successfully logs in, successfully executes the first two commands or so (ap-get update and one of svn updates), and then disconnects.
spawn ssh username@ipaddress
set timeout -1
expect "Are you sure you want to continue connecting" {send "yes\r"; exp_continue} "password:" {send "*******\r"; exp_continue
} "username@machine" {send "sudo apt-get update\r"}
expect "password" {send "*******\r"; exp_continue} "username@machine" {send "sudo svn update ~/folder1\r"}
expect "password" {send "*******\r"; exp_continue} "username@machine" {send "sudo svn update ~/folder2\r"}
expect "password" {send "*******\r"; exp_continue} "username@machine" {send "sudo svn update ~/folder3\r"}
expect "password" {send "*******\r"; exp_continue} "username@machine" {send "sudo reboot\r"}
close
source
share