Hi,
I wrote an Expect script which logs-in to a remote host then walks through a command list file and sends commands to the remote host step by step. Between two commands the script waits for the remote prompt and then proceeds with the next command. The script actually works fine so far, but sometimes the prompt string is not unique enough so that the script finds the remote prompt string within the actual output data and proceeds with the next command erroneously. I found this interesting article here which explains the problem a little bit more detailed:
http://linuxgazette.net/2013/01/adva...t-your-prompts
The remote host is a cisco switch and the prompt string can be for example "MyCoolCiscoSwitch#". It begins with a variable part - mostly the hostname - and ends with an "#" sign. I'm using the regular expression "(.*#$)" but it's still not unique enough.
Anyway...
My actual question is how can I catch the line that seems to contain my remote prompt string?
I'm thinking of something similar like this
expect {
-re "(.*#$)" {
puts "remote prompt string found in this line " [a damned cool function which shows the last captured line]
}
}
I need this for debugging purposes. It would be very helpful to see the line which causes my script to behave erroneous.
Thanks,