Here’s a simple expect example:
#!/usr/bin/expect -f spawn some-script-requiring-input.sh expect "Enter passphrase:" send ThisIsMyPassword\n interact
Another example using variables:
#!/usr/bin/expect -f set myhost MyCrazyBox spawn ssh $myhost "ls" expect $myhost send "MyPassword" interact
Another example installing a printer:
#!/usr/bin/expect -f spawn hp-setup -i -a -x -d hp:/net/hp_color_LaserJet_3500?zc=NPIF944C5 expect "Enter option" send \n expect "Do you accept the license terms" send \n expect eof
The “eof” is required to end the script cleanly.