Problem with Net::SSH and Case
For my first little Ruby project, I'm developing a script that will run through an array of linux/UNIX host names and perform actions on each (depending on what platform it is). However, it seems my code dies at a certain point when there is more to do.
First, it loads a few arrays with sample data. Then, it iterates through the array of platforms (Linux, Solaris, etc), and connects to it via SSH to perform commands remotely (in this example it only connects to Linux). However, it does not seem to get past the red area if I use the puts notification. When (puts "This is a Linux box!") is run, it displays the message fine, but then nothing else is displayed, no matter if its the very last line of the script or not. However, if you comment out the red line, the script runs fine.
Can anyone explain why this would happen? Thanks!
arrPlatforms = ["Linux", "Solaris"]
arrHostNames = ["linuxtest.com", "solaristest.com"]
arrUserNames = ["Joe", "Joe"]
arrUserPwds = ["mypassword1", "mypassword2"]
n = 0
while n < arrPlatforms.length
platform = arrPlatforms[n]
host_name = arrHostNames[n]
user_name = arrUserNames[n]
user_pwd = arrUserPwds[n]
puts "This is a Linux box!"
#INITIATE SSH CONNECTION
Net::SSH.start( host_name, user_name, user_pwd ) do |session|
shell = session.shell.sync
puts shell.send_command( "cat /proc/cpuinfo | grep 'model name' | sed 's/.*://g; s/^[ /t]*//'" ).stdout
puts "This is a Solaris box"
n += 1