Skip to main content
2 of 3
edited tags
Gilles 'SO- stop being evil'
  • 865.4k
  • 205
  • 1.8k
  • 2.3k

Help me understand this echo/spawn/send/expect construct

Here is a line from a bash script I am trying to understand:

echo "spawn myscript.sh arg1 arg2; expect \"Please enter your value: \"; send \"myval\r\"; expect eof" | expect

I think I understand the first expect and the send.

Q1: Does expect work only with spawn?

Q2: What is the purpose of the last expect after the pipe?

Q3: In general, can you guess what the original author of this line was attempting to accomplish?

amphibient
  • 12.8k
  • 19
  • 69
  • 88