Login To Various Devices
I'm trying to create a script that will login to various cisco devices. They all have the same username / password but the login method can be SSH or Telnet. I have pasted the current script I have been using. This has worked for the most part. The biggest problem is, after I have logged into a device, and the device times out, I get a script error popup for every one. It says:
ScriptError - Error: Connection Lost
File: C:blahblahblah/python.py Line 14
crt.Screen.WaitForString("sername:" or "login:")
I'm mostly looking for a way to do some error checking in the script to eliminate this constant error. I would love to be able to try SSH and fail back to Telnet if SSH is not available if possible too. Any suggestions would be appreciated.
The current script:
________________________________________
# $language = "Python"
# $interface = "1.0"
# Login to Cisco Devices
def main():
crt.Screen.Synchronous = True
#The above waits for a command prompt
crt.Session.Connect
crt.Screen.WaitForString("sername:" or "login:")
crt.Screen.Send("USERNAME\r")
crt.Screen.WaitForString("word:")
crt.Screen.Send("PASSWORD\r")
crt.Screen.Synchronous = False
main()
|