221 lines
4.3 KiB
Bash
221 lines
4.3 KiB
Bash
#!/usr/bin/expect
|
|
# Line | Location(AU/US) | Kit1/2
|
|
|
|
set iLine [lindex $argv 0]
|
|
set sLoc [lindex $argv 1]
|
|
set iKit [lindex $argv 2]
|
|
|
|
if { $sLoc == "US" } {
|
|
if { $iKit == 1 } {
|
|
|
|
puts "Line $iLine $sLoc $iKit"
|
|
set iPort [ expr $iLine + 2000 ]
|
|
set iTSLine [ expr $iLine + 2 ]
|
|
set sHost "192.168.5.7"
|
|
set iCPort 2323
|
|
set iLineDis [ expr $iLine + 0 ]
|
|
} else {
|
|
puts "Line $iLine $sLoc $iKit"
|
|
set iPort [ expr $iLine + 2010 ]
|
|
set iTSLine [ expr $iLine + 2 ]
|
|
set sHost "192.168.5.7"
|
|
set iCPort 2333
|
|
set iLineDis [ expr $iLine + 8 ]
|
|
}
|
|
} elseif { $iKit == 1 } {
|
|
puts "Line $iLine $sLoc $iKit"
|
|
set iPort [ expr $iLine + 2017 ]
|
|
set iTSLine [ expr $iLine + 17 ]
|
|
set sHost "192.168.5.56"
|
|
set iCPort 23
|
|
set iLineDis [ expr $iLine + 0 ]
|
|
} elseif { $iKit == 2 } {
|
|
puts "Line $iLine $sLoc $iKit"
|
|
set iPort [ expr $iLine + 2010 ]
|
|
set iTSLine [ expr $iLine + 10 ]
|
|
set sHost "192.168.5.56"
|
|
set iCPort 23
|
|
set iLineDis [ expr $iLine + 8 ]
|
|
} else {
|
|
puts "Line $iLine $sLoc $iKit"
|
|
set iPort [ expr $iLine + 2041 ]
|
|
set iTSLine [ expr $iLine + 41 ]
|
|
set sHost "192.168.5.20"
|
|
set iCPort 23
|
|
set iLineDis [ expr $iLine + 41 ]
|
|
set iLineDis "$iLine-$iLineDis"
|
|
}
|
|
|
|
spawn telnet $sHost $iCPort
|
|
send "clear line $iTSLine\r"
|
|
expect "confi"
|
|
send "\r"
|
|
send "\r"
|
|
expect "#\r"
|
|
sleep 1
|
|
send "clear line $iTSLine\r"
|
|
expect "confi"
|
|
send "\r"
|
|
send "\r"
|
|
expect "#\r"
|
|
send "quit\r"
|
|
expect "for"
|
|
sleep 1
|
|
|
|
spawn telnet $sHost $iPort
|
|
sleep 2
|
|
send "\r"
|
|
|
|
set iCount 0
|
|
|
|
puts "\rStartTest\r"
|
|
|
|
while { $iCount<3 } {
|
|
|
|
send "\r"
|
|
|
|
expect {
|
|
|
|
"Press RETURN to get started." {
|
|
|
|
send "\r"
|
|
send "\r"
|
|
}
|
|
|
|
"assword" {
|
|
send "cisco\r"
|
|
}
|
|
|
|
-re "User\:|Username\:|User Name" {
|
|
|
|
send "cisco\r"
|
|
expect "assword"
|
|
send "cisco\r"
|
|
|
|
expect {
|
|
"User" {
|
|
send "admin\r"
|
|
expect "assword"
|
|
send "Work1234\r"
|
|
|
|
expect {
|
|
"User" {
|
|
send "cisco\r"
|
|
expect "assword"
|
|
send "Work1234\r"
|
|
break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
"Connection closed by foreign host" {
|
|
spawn telnet $sHost $iPort
|
|
sleep 1
|
|
}
|
|
|
|
"initial configuration dialog" {
|
|
send "no\r"
|
|
|
|
expect {
|
|
"Would you like to terminate autoinstall" {
|
|
send "Yes\r"
|
|
}
|
|
|
|
"HTTP Secure server configuration not done" {
|
|
sleep 20
|
|
}
|
|
}
|
|
sleep 5
|
|
continue
|
|
}
|
|
|
|
-re "..>$|..#$" {
|
|
break
|
|
}
|
|
|
|
"switch:" {
|
|
|
|
|
|
set iCount2 0
|
|
puts "\rStartTest\r"
|
|
send "flash_init\r"
|
|
while { $iCount2<3 } {
|
|
|
|
expect {
|
|
|
|
"MORE" {
|
|
send " "
|
|
}
|
|
|
|
"switch:" {
|
|
|
|
send "set\r"
|
|
expect "switch:"
|
|
send "SWITCH_IGNORE_STARTUP_CFG=1\r"
|
|
expect "switch:"
|
|
|
|
send "delete flash:config.text\r"
|
|
expect {
|
|
|
|
"want to delete" {
|
|
send "y\r"
|
|
}
|
|
}
|
|
|
|
expect {
|
|
|
|
"switch:" {
|
|
send "boot\r"
|
|
expect {
|
|
-timeout 380
|
|
"Press RETURN to get start" { set iCount2 4 }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
incr iCount
|
|
}
|
|
|
|
send "\32"
|
|
send "\32"
|
|
send "\r"
|
|
send "en\r"
|
|
send "terminal length 0\r"
|
|
#expect "asdf"
|
|
#exit
|
|
expect {
|
|
|
|
-re "..#" {
|
|
|
|
send "sh inventory\r"
|
|
send "sh version\r"
|
|
send "sh post\r"
|
|
send "sh env all\r"
|
|
send "sh logging\r"
|
|
send "sh diagnostic result switch 1 detail\r"
|
|
send "sh diagnostic result slot all\r"
|
|
send "sh platform\r"
|
|
send "sh env stat\r"
|
|
send "sh power\r"
|
|
send "sh mod\r"
|
|
send "sh diagn res mod all\r"
|
|
|
|
expect {
|
|
-timeout 30
|
|
"asdf#" exit
|
|
}
|
|
}
|
|
}
|
|
|
|
puts "\rEndTest\r"
|
|
close
|
|
exit
|