From d9d67cefdeef375e4e3a4d04b1b190eca1c5543e Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 30 Sep 2020 14:29:38 -0600 Subject: [PATCH 1/2] scope changes --- cisco_wifi_ctl.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index 7743972b..fd270023 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -54,6 +54,7 @@ Q = '"' A = "'" FORMAT = '%(asctime)s %(name)s %(levelname)s: %(message)s' band = "a" +egg = None # think "eggpect" Need global scope for recovery def usage(): print("$0 used connect to controller:") @@ -151,7 +152,6 @@ def main(): print("cisco series {}".format(args.series)) print("scheme {}".format(args.scheme)) - egg = None # think "eggpect" try: if (scheme == "serial"): #eggspect = pexpect.fdpexpect.fdspan(telcon, logfile=sys.stdout.buffer) @@ -185,6 +185,7 @@ def main(): #9800 series if args.series == "9800": while logged_in_9800 == False and loop_count <= 2: + loop_count += 1 egg.sendline(CR) sleep(3) i = egg.expect_exact(["Escape character is '^]'.","WLC>","WLC#","User:","Password:","WLC(config)#","Bad secrets",pexpect.TIMEOUT],timeout=2) @@ -398,6 +399,7 @@ def main(): #9800 series if args.series == "9800": while logged_in_9800 == False and loop_count <= 2: + loop_count += 1 logg.info("9800 establishing Telnet egg {} ".format(egg)) sleep(5) egg.sendline(CR) @@ -481,7 +483,6 @@ def main(): egg.logfile = FileAdapter(logg) time.sleep(0.1) logged_in_9800 = False - loop_count = 0 found_escape = False if i == 1: @@ -605,7 +606,6 @@ def main(): egg.logfile = FileAdapter(logg) time.sleep(0.1) logged_in_9800 = False - loop_count = 0 found_escape = False if i == 6: logg.info("9800 recieved Bad secrets, to many password attempts i: {} before {} after {}".format(i, egg.before,egg.after)) @@ -626,7 +626,6 @@ def main(): egg.logfile = FileAdapter(logg) time.sleep(0.1) logged_in_9800 = False - loop_count = 0 found_escape = False if loop_count >= 3: From 623e666d14435800134a64e6372676990ced0e0c Mon Sep 17 00:00:00 2001 From: Chuck SmileyRekiere Date: Wed, 30 Sep 2020 14:39:41 -0600 Subject: [PATCH 2/2] need time for telnet to establish --- cisco_wifi_ctl.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cisco_wifi_ctl.py b/cisco_wifi_ctl.py index fd270023..bb55ce7c 100755 --- a/cisco_wifi_ctl.py +++ b/cisco_wifi_ctl.py @@ -187,7 +187,6 @@ def main(): while logged_in_9800 == False and loop_count <= 2: loop_count += 1 egg.sendline(CR) - sleep(3) i = egg.expect_exact(["Escape character is '^]'.","WLC>","WLC#","User:","Password:","WLC(config)#","Bad secrets",pexpect.TIMEOUT],timeout=2) if i == 0: logg.info("9800 found Escape character is '^] i: {} before: {} after: {}".format(i,egg.before,egg.after)) @@ -392,7 +391,7 @@ def main(): logg.info("Spawn: "+cmd+NL) egg = pexpect.spawn(cmd) egg.logfile = FileAdapter(logg) - time.sleep(0.1) + time.sleep(2) logged_in_9800 = False loop_count = 0 found_escape = False @@ -481,7 +480,7 @@ def main(): logg.info("Spawn: "+cmd+NL) egg = pexpect.spawn(cmd) egg.logfile = FileAdapter(logg) - time.sleep(0.1) + time.sleep(2) logged_in_9800 = False found_escape = False @@ -604,7 +603,7 @@ def main(): logg.info("Spawn: "+cmd+NL) egg = pexpect.spawn(cmd) egg.logfile = FileAdapter(logg) - time.sleep(0.1) + time.sleep(2) logged_in_9800 = False found_escape = False if i == 6: @@ -624,7 +623,7 @@ def main(): logg.info("Spawn: "+cmd+NL) egg = pexpect.spawn(cmd) egg.logfile = FileAdapter(logg) - time.sleep(0.1) + time.sleep(2) logged_in_9800 = False found_escape = False