Hello hello, did a quick search and didn't turn up anything helpful. I've got a book I'm sure has the answers, but I don't think I'll have time to finish it before this all has to work, so here goes~ if this isn't a good place to post and someone could direct me to another forum I'd appreciate that just as much as an answer, wasn't really sure where to go...
1 #!/usr/bin/expect
2 # To automate the sillyness of the crap IBM keeps sending me.
3 # Usage: ./san_support.sh <IP to rlogin> <Filename to tee>
4 #
5
6 if [catch {spawn rlogin [lindex $argv 0] | tee [lindex $argv 1]} reason]\
7 {
8 puts "Failure to spawn.\r"
9 puts "Reason: ${reason}\r"
10 }
11
12 expect "shell:"
13 send "<password>\r"
14 expect "->"
15 send "chall\r"
There's quite a few things wrong here, and I've purposefully included a few that I had removed trying to test specific elements. Questions are:
1) How do I spawn rlogin with the tee command? When I try to execute it as such it doesn't work, if I remove the | tee ... portion it will, and adding spawn in twice didn't seem to work.
2) The prompt I'm working with on the IBM SAN controller is '->' - if I expect "->" it errors out, I tried \\-> and \\-\\> but didn't seem to have any luck, I imagine this one is just me being really stupid somewhere.
Edit: Fixed number 2 - I had backwards slashes. Number one still stands though :x
Anyway, I hope that the above is clear, I'd appreciate any criticisms or suggestions as I am very very new to expect. Thanks in advance.
Edit: In my actual script I have the password where <password> is here and that part works, in case there is any unclarity with regards to that bit.
--
~Vryali