我正在尝试登录Cisco控制器并获取“ show ap summary”的结果。我认为与控制器的连接正在工作,并且我尝试了各种方法,但是我不知道如何获取“ show ap summary”的结果并将其用于我的python程序中进行解析。
import pexpect
from pexpect import pxssh
from time import sleep
m_localhost ='########'
username='######'
password='###########'
try:
try:
child=pexpect.spawn('ssh %s@%s' %(username,m_localhost))
#if verbose:
# child.logfile=sys.stdout
#child.timeout=5
child.expect('User: ')
child.sendline(username)
child.expect('Password:')
except Exception as e:
print(e)
child.sendline(password)
print("PASSWORD SENTTTTTTT")
child.expect('>')
#sleep(0.1)
#print("Expecting a command for Cisco")
child.sendline('config paging disable\n')
print('Disabled')
child.expect('>')
alldata=child.sendline('show ap summary')
#print(child.after)
except Exception as e:
print(e)
print("IN")
print('---------')
print(alldata)