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?

share|improve this question
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 Jan 20 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 Jan 20 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 Jan 20 at 17:09
1  
@icarus, you need a space between the opening brace and "echo" – glenn jackman Jan 20 at 17:38
    
Feel free to post your solution as an answer, uloco – Jeff Schaller Jan 21 at 1:15
up vote 2 down vote accepted

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"
share|improve this answer

Using a very simplistic expect script:

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

Running it:

$ expect -f script.expect
share|improve this answer

@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
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.