Posts

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

Another Way to login to SecureCrt using python if there is ">" operator is as follows : This below script will help you login as well as search for the string mentioned at the beginning and out if found or not ************************** # $language = "Python" # $interface = "1.0" # Website: www.ifconfig.it # License: https://creativecommons.org/licenses/by-sa/4.0/legalcode def main():     # CONNECTION DATA     hostIP = "X.X.X.X"     username = "XXXXX"     password = "XXXX"     enablePassword = "XXXXX"     prompt = "#"     # PARAMETERS     command = "XXXXX"     searchString = "XXXXX"     reloadCommand = "XXXX"     # LOGIN STRINGS     loginStrings = ["Username","Password:",">","Password:"]     sendString = [username,password,"enable",enablePassword]     crt.Screen.Synchronous = True     # CONN...

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 + ...