spawn, expect and send commands in Linux

Apr 10, 2022 · 1 min read · Post a comment

spawn, expect and send commands are usually part of SSH bash scripts. So, I’m going to briefly explain them, starting with expect since the rest of them are part of it.


  • Linux bash environment


spawn ssh -o \"StrictHostKeyChecking=no\" \"${USER}\"
expect \"${USER}'s password:\"
send \"${PASSWORD}\n\"


expect is a scripting utility that communicate with interactive scripts.

spawn starts a new process. For instance initiating SSH session as in the example above.

send writes to the spawned process standard input (std). It has a file descriptor value of 0.


Official expect documentation. On a side note, follow our official channel on Telegram.