Tuesday, October 4, 2022

[SOLVED] How to use expect to execute a jar and continuously hit enter?

Issue

To start from the beginning, I'm using ansible to open a Jar file in a linux environment.

Basically I do: java -jar someJarFile.jar, and it opens in command line. Now, it prompts me with several questions which can be passed by hitting Return multiple times. Finally the jar will produce a WAR file...

Here's where I need your help. I want to use ansible to call an expect script so that it can automatically execute the jar and continuously hit enter until the jar is successfully completed/installed.


Solution

try

yes "" | java -jar someJarFile.jar


Answered By - glenn jackman
Answer Checked By - Senaida (WPSolving Volunteer)