echo "name"
read name
if [ "$name" == "abcd" ]; then
echo "hi"
echo "hello"
echo "bye"
fi
을 다음 쉘 스크립트 details.sh가 있다고 가정하자/ExpectJ 전문가 예상 ========================
그리고 이것은 내 자바 코드
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.
그 일이야? 아니면이 왜 어떤 생각입니다 그런 식으로 행동해야만할까요? 스크립트 출력을 보면