I am working on automating the interactive command line of a Java program in bash to verify that the program produces the correct output for input (basically testing a module with a low level of service in bash).
For example, if I have a Java program that asks the user to enter the full name and then displays only their name, it should look something like this:
Enter your name: John Doe
John
Where user "John Doe" was entered by the user.
A simple bash command to run might look like this:
OUTPUT=`echo "John Doe" | java NameReader`
or
OUTPUT=`java NameReader <<< "John Doe"`
The problem with both of them is that $ OUTPUT now contains the following:
Enter your name: John
Since the text that was sent to stdin (and its accompanying new line) is not reproduced at the output of the program as we see it in the console.
$OUTPUT :
Enter your name: John Doe
John
:
Enter your name:
John
( , , )
bash ( java-), , stdin, stdout "", java, ?
( : , spawn/expect , , , , )