V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
mikefy
V2EX  ›  问与答

Python 的 pexpect 模块的问题

  •  1
     
  •   mikefy · 2019-01-22 17:52:48 +08:00 · 1615 次点击
    这是一个创建于 1913 天前的主题,其中的信息可能已经有所发展或是发生改变。

    使用这个模块进行 scp 命令的时候, 因为 ip 不在已知的主机列表中, 所以有一个需要输入 yes/no 的动作,

    The authenticity of host 'X.X.X.X (X.X.X.X)' can't be established.

    ECDSA key fingerprint is SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.

    ECDSA key fingerprint is MD5:67:2a:d8:dc:13:9XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.

    Are you sure you want to continue connecting (yes/no)?

    我的判断是: i = child.expect(['denied', 'yes/no', 'assword', '100%'], timeout=10)

    但是每次这里的检测都过不去, 不知道为什么

    pexpect.exceptions.TIMEOUT: Timeout exceeded.

    <pexpect.pty_spawn.spawn object at 0x7f22d181ecd0>

    command: /usr/bin/scp

    args: ['/usr/bin/scp', '/root/.ssh/id_rsa.pub', '[email protected]:/root/.ssh/authorized_keys']

    buffer (last 100 chars): ')? '

    before (last 100 chars): ')? '

    after: <class 'pexpect.exceptions.TIMEOUT'>

    match: None

    match_index: None

    exitstatus: None

    flag_eof: False

    pid: 11859

    child_fd: 5

    closed: False

    timeout: 30

    delimiter: <class 'pexpect.exceptions.EOF'>

    logfile: None

    logfile_read: None

    logfile_send: None

    maxread: 2000

    ignorecase: False

    searchwindowsize: None

    delaybeforesend: 0.05

    delayafterclose: 0.1

    delayafterterminate: 0.1

    searcher: searcher_re:

    0: EOF

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2726 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 15:40 · PVG 23:40 · LAX 08:40 · JFK 11:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.