trying to pull data from a wireless controller. the command is show ap auto-rf band can be either 802.11a 802.11b or 802.11-abgn ap-name is arbitrary
sample output:
(Cisco Controller) >show ap auto-rf 802.11-abgn Hallway38
Number Of Slots.................................. 2
AP Name.......................................... Hallway38
MAC Address...................................... a0:e0:af:33:d0:bc
Slot ID........................................ 0
Radio Type..................................... RADIO_TYPE_80211abgn
Current TX/RX Band............................. 80211 2.4G band
Sub-band Type.................................. All
Noise Information
Noise Profile................................ PASSED
Channel 1.................................... -90 dBm
Channel 2.................................... -77 dBm
Channel 3.................................... -88 dBm
Channel 4.................................... -93 dBm
Channel 5.................................... -91 dBm
Channel 6.................................... -88 dBm
Channel 7.................................... -93 dBm
error output: File "./wlc-auto-rf.py", line 34, in child.sendline ('show ap auto-rf' ['radio']['apname']) TypeError: string indices must be integers, not str
Any help is appreciated.
here is the script:
!/usr/bin/python
#
# requires python pexpect module
#
import pexpect
import sys
firstarg=sys.argv[0]
address=sys.argv[1]
username=sys.argv[2]
password=sys.argv[3]
radio=sys.argv[4]
apname=sys.argv[5]
output=sys.argv[6]
child = pexpect.spawn ('ssh' , [address])
child.expect ('User:')
child.sendline (username)
child.expect ('Password:')
child.sendline (password)
child.expect ("Controller")
child.sendline ('config paging disable')
#
child.expect ("Controller")
child.sendline ('show ap auto-rf' ['radio']['apname'])
child.logfile = open(output , "w")
child.expect ("Controller")
child.sendline ('logout')
child.expect('(y/N)')
child.sendline ('N')
child.expect(pexpect.EOF)
I was able to fix it using string concatenation to add the variables together into one string child.sendline ('show ap auto-rf '+radio+' '+apname)