Ok when it comes to programming ANYTHING I am pretty slow. I needed to change the firewall ruleset on quite a few ESX servers and it seemed like a script was in order to make this change for me. However, since I could not get the Opsware client to run a script remotely (that was part of the problem) i needed to figure out an alternative method.
Enter EXPECT.. I had heard it mentioned before but not really understood what it did. Basically you can open a connection to another system and if you can tell the script what to "expect" then it will know what to send it in return.. pretty cool huh.. This is the part where my wife's eyes glaze over.
Basically what I was doing is this...
spawn ssh email@example.com
expect "someuse@somemachine's password:"
And so on.. you get the idea. BUT.. is there not always a but... the issue I was having was that the prompt was on a VMware ESX server and looked like [usename@hostname username]$. I entered the text verbatim so that the expect showed the brackets etc. It puked. But by removing the brackets and only going to the end of the first word it works. Example..
expect "someuser@hostname" works but expect "[usename@hostname username]$" does not. Go figure. So I am going to stop while I am ahead today and revel in my glory....
Just rember... You Stay Classy San Diego.