I have a shell script, test.sh, that internally invokes a Java application MyApp.
#!/bin/bash
# Invoking MyApp
java MyApp
MyApp reads 2 parameters, username and password, from the console. Running this script will execute the Java app which will prompt the user to enter a username and password
Username: user
Password: ****
I want to automate the execution of this shell script. How can I pass the username and password as parameters to the script test.sh?
What I've tried:
Used the indirection operator with a file containing the parameters
$ ./test.sh <input
Used the shortcut for the above method
$ ./test.sh <<!
user
password
!
In both cases Console console = System.console();
inside MyApp.java sets console
as null.
PS: Looking for ways to accomplish this without modifying the script or the Java app. "No, this cannot be done!" is also an acceptable answer.