Got my first script working and very excited about it. Modifying it to work with functions and running into issues. Appreciate help with this so I can better understand. As I understand I can define a function and then I can call it again. So I created a function below "sh_ap_sum". I'm trying to run that so that it dumps the output of the command to a file.
Then I am calling that function again with "sh_ap_sum(cdp)" and trying to display the output of the file in the terminal window. Am I completely doing it wrong any hints will be appreciated greatly. Thank you.
from netmiko import ConnectHandler
import sys
def sh_ap_sum(ap_sum):
ipaddr = input('IP:''')
net_connect = ConnectHandler(ip = ipaddr,port = 22,username = 'admin',password = 'mypassword',device_type = 'cisco_wlc_ssh')
net_connect.find_prompt()
'(Cisco Controller) >'
output = net_connect.send_command('show ap summary')
sys.stdout = open('wlccon.txt', 'w')
net_connect.disconnect()
sh_ap_sum(cdp)
output = net_connect.send_command('show ap cdp ne all')
print(output)