Допустим, у меня есть следующий скрипт: details.sh
echo "name"
read name
if [ "$name" == "abcd" ]; then
echo "hi"
echo "hello"
echo "bye"
fi
=============================================
А это мой код Java
ExpectJ exp = new ExpectJ();
String cmd = "sh details.sh"; //Command for execution of **details.sh**
Spawn s = exp.spawn(cmd); //Spawns the process **details.sh**
s.expect("name"); //Expecting "name" from the script
s.send("abcd"); //When successful, it sends **abcd** as the input to the script
//Now the script will compare the input(given by java code) with the pre-fed one (the one in the script)
s.expect("hi"); //according to me only **hi** must be displayed,but the java console is taking and displaying all the consecutive echo statements from the script.
Есть идеи, почему это происходит? Или оно должно вести себя только так?