Hi,
I coded a script in expect. That logs into several switches with different OS versions. The command order I'll execute on the switches depends on its OS version. E.g. it looks like, when I log into different OS:
=============================
Escape character is '^]'.
Fabric OS (tm) Release v3.2.1c
login:
=============================
Escape character is '^]'.
Fabric OS (switch)
Fabos Version 5.3.0c
switch login:
=============================
The idea was to parse the lines on "3.2.1" or "5.3.0". Does anyone can help me on that task? I tried already simple things like:
expect {
"3.2.1" { .. }
"5.3.0" { .. }
}
But that doesn' work. I assume, because the key string is not in the last line. My last idea was to do something like:
spawn telnet $hostname
expect "login: " {send "$user\r"}
expect "Password:" {send "$password1\r"}
append output "$expect_out(buffer)"
set timeout 50
if [ string match "*3.2.1*" $expect_out(buffer) ] {
}
else if [ string match "*5.3.0*" $expect_out(buffer) ]
}
But doesn't work as well. Any other ideas on how to make the fork?
Cheers,
Jack
I coded a script in expect. That logs into several switches with different OS versions. The command order I'll execute on the switches depends on its OS version. E.g. it looks like, when I log into different OS:
=============================
Escape character is '^]'.
Fabric OS (tm) Release v3.2.1c
login:
=============================
Escape character is '^]'.
Fabric OS (switch)
Fabos Version 5.3.0c
switch login:
=============================
The idea was to parse the lines on "3.2.1" or "5.3.0". Does anyone can help me on that task? I tried already simple things like:
expect {
"3.2.1" { .. }
"5.3.0" { .. }
}
But that doesn' work. I assume, because the key string is not in the last line. My last idea was to do something like:
spawn telnet $hostname
expect "login: " {send "$user\r"}
expect "Password:" {send "$password1\r"}
append output "$expect_out(buffer)"
set timeout 50
if [ string match "*3.2.1*" $expect_out(buffer) ] {
}
else if [ string match "*5.3.0*" $expect_out(buffer) ]
}
But doesn't work as well. Any other ideas on how to make the fork?
Cheers,
Jack