首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用pexpect模块的游戏手册问题

使用pexpect模块的游戏手册问题
EN

Stack Overflow用户
提问于 2021-09-03 09:01:07
回答 1查看 340关注 0票数 0

有人能帮忙解决这个问题吗?对于python2,解释器不能使用pexpect模块:(一点也不使用。使用python3,我得到了错误。

我试图通过安装pexpect模块来工作arrond,但没有成功。

=======================================

和平执行方案模块:

root@localhost ansible_epo_test# pip显示了pexpect降级:Python2.7于2020年1月1日结束了它的生命。请升级Python,因为Python2.7已不再维护。pip 21.0将在2021年1月放弃对Python2.7的支持。有关pip中Python2支持的更多细节,请参见https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip21.0将删除对此功能的支持。名称: pexpect版本: 3.3摘要: Pexpect允许轻松控制交互式控制台应用程序。主页:http://pexpect.readthedocs.org/作者:诺亚·斯波里尔;托马斯·克鲁弗;杰夫·夸斯特作者-电子邮件: noah@noah.org;thomas@kluyver.me.uk;contact@jeffquast.com许可证: ISC许可证位置: /usr/lib/python2.7/site-packages : Required-by: root@localhost ansible_epo_test# pip-3显示pexpect名称: pexpect版本: 4.8.0摘要: Pexpect允许轻松控制交互式控制台应用程序。主页:https://pexpect.readthedocs.io/作者: Noah;Thomas;Jeff作者-电子邮件: noah@noah.org,thomas@kluyver.me.uk,contact@jeffquast.com许可证: ISC许可证位置:/usr/local/lib/python3.6/site-包需要: ptyprocess root@localhost ansible_epo_test# pip-3列表废弃:默认格式将在未来切换到列。您可以使用--format=(旧式多列)(或在列表部分下的format=(旧版)中定义一个pip.conf )来禁用此警告。Jinja2 (2.11.1) MarkupSafe (1.1.1) root (4.8.0) pip (9.0.3) ptyprocess (0.7.0) PyYAML (5.3.1) rpm (4.11.3) setuptools (39.2.0) 6 (1.14.0) root@localhost ansible_epo_test#

可识别代码:

代码语言:javascript
复制
- name: "Install the patch .jar "
  expect:
    command: "/opt/ibm/cics/bin/TXSeriesFixInstaller.sh {{patch_name}}"
    responses:
      '.*Press 1 for Installation, 2 to Usage or 3 to Cancel.*': '1'
      '.*Do you want to proceed?.*': 'y'
    echo: yes
    chdir: "{{installation_dir}}/{{product_name}}"
  vars:
    ansible_python_interpreter: /usr/bin/python3
  become: yes
  become_user: root
  register: install_patch_execution
  ignore_errors: yes
  when: '".jar" in patch_name'

产出:

代码语言:javascript
复制
<172.18.19.182> ESTABLISH SSH CONNECTION FOR USER: None
<172.18.19.182> SSH: EXEC sshpass -d9 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/1106f609b6 172.18.19.182 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /tmp/ansible-tmp-1630657688.0494435-190630914787996 `" && echo ansible-tmp-1630657688.0494435-190630914787996="` echo /tmp/ansible-tmp-1630657688.0494435-190630914787996 `" ) && sleep 0'"'"''
<172.18.19.182> (0, b'ansible-tmp-1630657688.0494435-190630914787996=/tmp/ansible-tmp-1630657688.0494435-190630914787996\n', b'')
Using module file /usr/local/lib/python3.6/site-packages/ansible/modules/commands/expect.py
<172.18.19.182> PUT /root/.ansible/tmp/ansible-local-29887paj4oih0/tmplewouwv_ TO /tmp/ansible-tmp-1630657688.0494435-190630914787996/AnsiballZ_expect.py
<172.18.19.182> SSH: EXEC sshpass -d9 sftp -o BatchMode=no -b - -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/1106f609b6 '[172.18.19.182]'
<172.18.19.182> (0, b'sftp> put /root/.ansible/tmp/ansible-local-29887paj4oih0/tmplewouwv_ /tmp/ansible-tmp-1630657688.0494435-190630914787996/AnsiballZ_expect.py\n', b'')
<172.18.19.182> ESTABLISH SSH CONNECTION FOR USER: None
<172.18.19.182> SSH: EXEC sshpass -d9 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/1106f609b6 172.18.19.182 '/bin/sh -c '"'"'chmod u+x /tmp/ansible-tmp-1630657688.0494435-190630914787996/ /tmp/ansible-tmp-1630657688.0494435-190630914787996/AnsiballZ_expect.py && sleep 0'"'"''
<172.18.19.182> (0, b'', b'')
<172.18.19.182> ESTABLISH SSH CONNECTION FOR USER: None
<172.18.19.182> SSH: EXEC sshpass -d9 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/1106f609b6 -tt 172.18.19.182 '/bin/sh -c '"'"'sudo -H -S -n  -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-bikuwrrsbrvqqqpnsttxannmfqpdgptf ; /usr/bin/python3 /tmp/ansible-tmp-1630657688.0494435-190630914787996/AnsiballZ_expect.py'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
<172.18.19.182> (1, b'Traceback (most recent call last):\r\n  File "/tmp/ansible-tmp-1630657688.0494435-190630914787996/AnsiballZ_expect.py", line 102, in <module>\r\n    _ansiballz_main()\r\n  File "/tmp/ansible-tmp-1630657688.0494435-190630914787996/AnsiballZ_expect.py", line 94, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File "/tmp/ansible-tmp-1630657688.0494435-190630914787996/AnsiballZ_expect.py", line 40, in invoke_module\r\n    runpy.run_module(mod_name=\'ansible.modules.commands.expect\', init_globals=None, run_name=\'__main__\', alter_sys=True)\r\n  File "/usr/lib64/python3.6/runpy.py", line 205, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code\r\n    mod_name, mod_spec, pkg_name, script_name)\r\n  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File "/tmp/ansible_expect_payload_bxa5j6_h/ansible_expect_payload.zip/ansible/modules/commands/expect.py", line 246, in <module>\r\n  File "/tmp/ansible_expect_payload_bxa5j6_h/ansible_expect_payload.zip/ansible/modules/commands/expect.py", line 205, in main\r\n  File "/usr/local/lib/python3.6/site-packages/pexpect/run.py", line 100, in run\r\n    cwd=cwd, env=env, **kwargs)\r\n  File "/usr/local/lib/python3.6/site-packages/pexpect/pty_spawn.py", line 205, in __init__\r\n    self._spawn(command, args, preexec_fn, dimensions)\r\n  File "/usr/local/lib/python3.6/site-packages/pexpect/pty_spawn.py", line 304, in _spawn\r\n    cwd=self.cwd, **kwargs)\r\n  File "/usr/local/lib/python3.6/site-packages/pexpect/pty_spawn.py", line 315, in _spawnpty\r\n    return ptyprocess.PtyProcess.spawn(args, **kwargs)\r\n  File "/usr/local/lib/python3.6/site-packages/ptyprocess/ptyprocess.py", line 336, in spawn\r\n    raise exception\r\nOSError: [Errno 8] Exec format error\r\n', b'Shared connection to 172.18.19.182 closed.\r\n')
<172.18.19.182> Failed to connect to the host via ssh: Shared connection to 172.18.19.182 closed.
<172.18.19.182> ESTABLISH SSH CONNECTION FOR USER: None
<172.18.19.182> SSH: EXEC sshpass -d9 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o ConnectTimeout=10 -o ControlPath=/root/.ansible/cp/1106f609b6 172.18.19.182 '/bin/sh -c '"'"'rm -f -r /tmp/ansible-tmp-1630657688.0494435-190630914787996/ > /dev/null 2>&1 && sleep 0'"'"''
<172.18.19.182> (0, b'', b'')
The full traceback is:
Traceback (most recent call last):
  File "/tmp/ansible-tmp-1630657688.0494435-190630914787996/AnsiballZ_expect.py", line 102, in <module>
    _ansiballz_main()
  File "/tmp/ansible-tmp-1630657688.0494435-190630914787996/AnsiballZ_expect.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/tmp/ansible-tmp-1630657688.0494435-190630914787996/AnsiballZ_expect.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible.modules.commands.expect', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_expect_payload_bxa5j6_h/ansible_expect_payload.zip/ansible/modules/commands/expect.py", line 246, in <module>
  File "/tmp/ansible_expect_payload_bxa5j6_h/ansible_expect_payload.zip/ansible/modules/commands/expect.py", line 205, in main
  File "/usr/local/lib/python3.6/site-packages/pexpect/run.py", line 100, in run
    cwd=cwd, env=env, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pexpect/pty_spawn.py", line 205, in __init__
    self._spawn(command, args, preexec_fn, dimensions)
  File "/usr/local/lib/python3.6/site-packages/pexpect/pty_spawn.py", line 304, in _spawn
    cwd=self.cwd, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pexpect/pty_spawn.py", line 315, in _spawnpty
    return ptyprocess.PtyProcess.spawn(args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/ptyprocess/ptyprocess.py", line 336, in spawn
    raise exception
OSError: [Errno 8] Exec format error
fatal: [172.18.19.182]: FAILED! => {
    "changed": false,
    "module_stderr": "Shared connection to 172.18.19.182 closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible-tmp-1630657688.0494435-190630914787996/AnsiballZ_expect.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/tmp/ansible-tmp-1630657688.0494435-190630914787996/AnsiballZ_expect.py\", line 94, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/tmp/ansible-tmp-1630657688.0494435-190630914787996/AnsiballZ_expect.py\", line 40, in invoke_module\r\n    runpy.run_module(mod_name='ansible.modules.commands.expect', init_globals=None, run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\r\n    mod_name, mod_spec, pkg_name, script_name)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/tmp/ansible_expect_payload_bxa5j6_h/ansible_expect_payload.zip/ansible/modules/commands/expect.py\", line 246, in <module>\r\n  File \"/tmp/ansible_expect_payload_bxa5j6_h/ansible_expect_payload.zip/ansible/modules/commands/expect.py\", line 205, in main\r\n  File \"/usr/local/lib/python3.6/site-packages/pexpect/run.py\", line 100, in run\r\n    cwd=cwd, env=env, **kwargs)\r\n  File \"/usr/local/lib/python3.6/site-packages/pexpect/pty_spawn.py\", line 205, in __init__\r\n    self._spawn(command, args, preexec_fn, dimensions)\r\n  File \"/usr/local/lib/python3.6/site-packages/pexpect/pty_spawn.py\", line 304, in _spawn\r\n    cwd=self.cwd, **kwargs)\r\n  File \"/usr/local/lib/python3.6/site-packages/pexpect/pty_spawn.py\", line 315, in _spawnpty\r\n    return ptyprocess.PtyProcess.spawn(args, **kwargs)\r\n  File \"/usr/local/lib/python3.6/site-packages/ptyprocess/ptyprocess.py\", line 336, in spawn\r\n    raise exception\r\nOSError: [Errno 8] Exec format error\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}
...ignoring

谢谢你,

EN

回答 1

Stack Overflow用户

发布于 2021-09-03 12:28:06

所犯的错误是关于谢邦#!/usr.在脚本"/opt/ibm/cics/bin/TXSeriesFixInstaller.sh“中

脚本是由IBM提供的,所以我无法亲自修复它,因此为了修复,我使用了"ksh /opt/ibm/cics/bin/TXSeriesFixInstaller.sh“

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69042221

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档