编程语言
首页 > 编程语言> > 从bash发送“输入密钥”到python脚本

从bash发送“输入密钥”到python脚本

作者:互联网

我试图用bash脚本自动化我的ubuntu设置并遇到以下问题:

我希望脚本在运行umake ide eclipse时自动发送一个输入击键(这会从终端安装eclipse ide).

这是标准输出,当从没有脚本的终端运行时:

$umake ide eclipse
Choose installation path: /home/gn4i/.local/share/umake/ide/eclipse
<need to press enter>
Downloading and installing requirements      

通常我会用echo |来做这个umake ide eclipse,但我总是得到以下错误

 $echo | umake ide eclipse
Choose installation path: Choose installation path: ERROR: Unhandled exception
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/umake/tools.py", line 158, in wrapper
    function(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/umake/ui/__init__.py", line 42, in display
    cls.currentUI._display(contentType)
  File "/usr/lib/python3/dist-packages/umake/ui/cli/__init__.py", line 61, in _display
    contentType.run_callback(result=rlinput(contentType.content, contentType.default_input))
  File "/usr/lib/python3/dist-packages/umake/ui/cli/__init__.py", line 41, in rlinput
    return input(prompt + " ")
EOFError: EOF when reading a line

如何自动完成此安装?

解决方法:

我设法用屏幕方法解决了它.
这在后台运行,我没有看到进展,但这对我来说没问题

screen -d -m -S umake-eclipse
screen -S umake-eclipse -p 0 -X stuff "umake ide eclipse\n\n"

标签:python,bash,shell,python3,shell-script
来源: https://codeday.me/bug/20190816/1668645.html