Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法将2个变量传递给pexpect;字符串索引必须是整数,而不是str_Python_Ssh_Pexpect - Fatal编程技术网

Python 无法将2个变量传递给pexpect;字符串索引必须是整数,而不是str

Python 无法将2个变量传递给pexpect;字符串索引必须是整数,而不是str,python,ssh,pexpect,Python,Ssh,Pexpect,试图从无线控制器中提取数据。 命令为show ap auto rf 频带可以是802.11a 802.11b或802.11-abgn ap名称是任意的 样本输出: (思科控制器)>显示ap自动射频802.11-abgn走廊38 Number Of Slots.................................. 2 AP Name.......................................... Hallway38 MAC Address............

试图从无线控制器中提取数据。 命令为show ap auto rf 频带可以是802.11a 802.11b或802.11-abgn ap名称是任意的

样本输出:

(思科控制器)>显示ap自动射频802.11-abgn走廊38

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
错误输出: 文件“/wlc auto rf.py”,第34行,在 child.sendline('show ap auto rf'['radio']['apname'])) TypeError:字符串索引必须是整数,而不是str

感谢您的帮助

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)

我能够使用字符串连接将变量添加到一个字符串中来修复它
child.sendline('show ap auto rf'+radio+''+apname)

为什么投票失败?