正在使用Pexpect的ssh来写下一个脚本编译命令选项,ssh的自动化看起来像这样,Pexpect的SSH无法处理
enter code here
child = ssh_expect('root', server2, cmd)
child.expect(pexpect.EOF)
print child.before
其中cmd是这样的:
cmd = "./configure CFLAGS=\"-g -O0 -DDEBUG\""
的问题发生在于它说,
configure: error: unrecognized option: -O0
而如果使用commands.getoutput运行相同的命令,则它会正确执行。
问题这种错误正在产生的问题是什么,我该如何根除这一错误?
在此先感谢:)
ssh_expect函数是否是您自己创建的?它到底做了什么? –
yes Erik,ssh_expect是由我创建的只是使用pexpect,它的工作方式如下,ssh_expect(user,hostname,cmd): ssh_newkey ='你确定要继续连接' child = pexpect.spawn('ssh- l%s%s%s'%(user,hostname,cmd),timeout = 3600) child.sendline('yes') child.expect('password:') – OpenFile