improved sending multiple commands on single pompt

This commit is contained in:
Chuck SmileyRekiere
2020-09-17 09:42:23 -06:00
parent c81bb6d601
commit 4451dcc606

View File

@@ -813,17 +813,17 @@ def main():
if i == 0: if i == 0:
print("elevated to (config)#") print("elevated to (config)#")
command = "wlan %s %s %s"%(args.wlan, args.wlanID, args.wlan) command = "wlan %s %s %s"%(args.wlan, args.wlanID, args.wlan)
print("open network command {}".format(command))
egg.sendline(command) egg.sendline(command)
j = egg.expect_exact(["(config-wlan)#",pexpect.TIMEOUT],timeout=2) j = egg.expect_exact(["WLC(config-wlan)#",pexpect.TIMEOUT],timeout=2)
if j == 0: if j == 0:
for command in ["shutdown","no security wpa","no security wpa wpa2","no security wpa wpa2 ciphers aes", for command in ["shutdown","no security wpa","no security wpa wpa2","no security wpa wpa2 ciphers aes",
"no security wpa akm dot1x","no shutdown","end"]: "no security wpa akm dot1x","no shutdown","end"]:
egg.sendline(command) egg.sendline(command)
sleep(0.1) sleep(0.1)
k = egg.expect_exact(["(config-wlan)#",pexpect.TIMEOUT],timeout=2) k = egg.expect_exact(["WLC(config-wlan)#",pexpect.TIMEOUT],timeout=2)
if k == 0: if k == 0:
print("command sent: {}".format(command)) print("command sent: {}".format(command))
egg.sendline("end")
if k == 1: if k == 1:
print("command time out: {}".format(command)) print("command time out: {}".format(command))
egg.sendline("end") egg.sendline("end")