Posts

Showing posts with the label python login

Python Login Script for Cisco 2k Series Routers and display the command output in the window

Python Login Script for Cisco 2k Series Routers and display the command output in the window # $language = "Python" # $interface = "1.0" # Connect to a SSH2 and automate the initial login sequence. # Note that synchronous mode is enabled to prevent server output from # potentially being missed. def main(): crt.Screen.Synchronous = True # connect to host on port 23 (the default telnet port) # # send username and enter crt.Screen.WaitForString("name:") crt.Screen.Send("XXX\r") # send password and enter crt.Screen.WaitForString("assword:") crt.Screen.Send("XXXX\r") crt.Screen.WaitForString("#") szPrompt = "CoreStack#" # get the script tab objTab = crt.GetScriptTab() objTab.Screen.Synchronous = True objTab.Screen.IgnoreEscape = True #this is show interface description | include AP szCommand = "sh int des | i AP" objTab.Screen.Send(szCommand + ...