3

I am trying to automate my ubuntu setup with a bash script and got the following problem:

I want the script to automatically send a enter keystroke, when running umake ide eclipse (this installs eclipse ide from the terminal).

This is the standard output, when running from the terminal without a script:

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

Normally I would do this with echo | umake ide eclipse, but I always get the following error

 $ 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

How can I automate this installation?

5
  • 1
    Maybe {echo ; sleep 5 ; } | umake ide eclipse ? The error message is complaining about EOF so we keep the pipe open for another 5 seconds. Just a guess.
    – icarus
    Commented Jan 20, 2017 at 16:42
  • solved it with a screen approach. This runs in the background and i dont see the progress, but this is ok for me: screen -d -m -S umake-eclipse screen -S umake-eclipse -p 0 -X stuff "umake ide eclipse\n\n"
    – uloco
    Commented Jan 20, 2017 at 17:03
  • @icarus: Your solution does not work. bash: syntax error near unexpected token }'` It also does not work, when I replace the curly braces with round braces.
    – uloco
    Commented Jan 20, 2017 at 17:09
  • 1
    @icarus, you need a space between the opening brace and "echo" Commented Jan 20, 2017 at 17:38
  • Feel free to post your solution as an answer, uloco
    – Jeff Schaller
    Commented Jan 21, 2017 at 1:15

3 Answers 3

2

I managed to solved it with a screen approach. This runs in the background and I don't see the progress, but this is ok for me

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

Using a very simplistic expect script:

spawn umake ide eclipse
expect "Choose installation path:" { sleep 1; send "\r" }

Running it:

$ expect -f script.expect
1

@Kusalananda's answer won't work in practice as the execution of the umake command stops after the send command.

Here's an extended, working solution:

#!/usr/bin/expect

spawn umake ide eclipse
expect "Choose installation path:" { send "\r" }
interact

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .