我已从https://gist.github.com/anthonyeden/8488763下载了wexpect.py。我把它保存为wexpect.py。 导入此模块
import wexpect.py
child = wexpect.spawn('ssh.exe %s@%s' % ('server1','a.b.c.d'))
我收到以下错误
>>> child = wexpect.spawn('ssh.exe %s@%s' % ('server1','a.b.c.d'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "wexpect.py", line 279, in spawn
return spawn_windows(command, args, timeout, maxread,
search windowsize, logfile, cwd, env)
File "wexpect.py", line 1653, in __init__
self._spawn (command, args)
File "wexpect.py", line 1698, in _spawn
raise ExceptionPexpect ('The command was not found or was not
executable: %s.' % self.command)
ExceptionPexpect: The command was not found or was not executable:
ssh.exe server1@a.b.c.d.
我能够在shell提示符下执行。安装cygwin后,ssh.exe已添加到PATH
ssh server1@a.b.c.d
我还在环境变量(用户和系统)中设置PYTHONPATH以包含c:\ cygwin64 \ bin
这是怎么做到的?
所有帮助将不胜感激
此致 内甚
答案 0 :(得分:-1)
简介:
分别提供可执行文件的参数:
n
详细信息:
这是wexpect产生的标头:
import wexpect.py
child = wexpect.spawn('ssh.exe', ['%s@%s', '%', "('server1','a.b.c.d')"])
此方法分别等待可执行文件和参数。