正在使用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