【发布时间】:2012-10-12 19:51:24
【问题描述】:
我一直在尝试在 Windows 平台上运行此命令以从 .py 进行 ssh:
child = winpexpect.spawn('ssh %s@%s' % ('myID','m.y.i.p'))
它的功能应该与 pexpect 类似,但我收到此错误:
pexpect.ExceptionPexpect: The command was not found or was not executable: ssh.
我已经确认 C:\rhcygwin\bin 在我的路径中。关于如何指示 .py 文件找到 ssh 命令的任何建议?
编辑:我改变了方法:在我的 .py 中运行此代码
command = ['bash', '-c', './myssh.sh']
proc = subprocess.Popen(command, stdout = subprocess.PIPE)
它很简陋,但它会成功连接。
【问题讨论】: