Reputation: 11
There is my code
import re
import netmiko
import sys
import json
def get_results(ip, login, password):
device = {
'device_type': 'cisco_asa',
'ip': ip,
'username': login,
'password': password,
'secret': password,
'global_delay_factor': 2
}
try:
net_connect = netmiko.ConnectHandler(**device)
except Exception as e:
print("Ошибка при подключении:", e)
return
try:
output = net_connect.send_command_timing("show aaa-server NPS_MFA_TEST", strip_prompt=False)
print(output)
except Exception as e:
print("Ошибка при выполнении команды:", e)
net_connect.disconnect()
return
result = {}
match_group = re.search(r"Server Group:\s+(\S+)", output)
if match_group:
result["Server Group"] = match_group.group(1)
match_address = re.search(r"Server Address:\s+(\S+)", output)
if match_address:
result["Server Address"] = match_address.group(1)
return json.dumps(result)
if __name__ == "__main__":
if len(sys.argv) == 4:
ip = sys.argv[1]
username = sys.argv[2]
password = sys.argv[3]
result = get_results(ip, username, password)
print(result)
else:
print("Неверное количество аргументов")
But the result is sending shorted output(need to press Enter or Space buttons). How can i skip it?
I've tried to add 'global_delay_factor': 2
in device object and I've tried to put strip_prompt=False
as send_command
argument. But that didn't work
Upvotes: 1
Views: 389
Reputation: 3040
You need to send the command terminal length 0
as the first command, after you've logged into your Cisco device.
Upvotes: 1
Reputation: 50
I am not sure about that,try to press q in terminal may be accessible
Upvotes: -1