linux-script-expect-continued
to execute the file with the "expect interpreter" you must begin the script with one of the three (depending where your expect binary has been installed)
!/usr/bin/expect
!./expect -f
!../expect -f
DON'T FORGET to chmod +x scriptname.sh
VARIABLES
test.sh
!/usr/bin/expect
set password [lindex $argv 0] send $password\n
./test.sh testvar
testvar
USING EXPECT WITH OTHER BINARIES (with the "spawn" command) THE INTERACT command returns control to the command line prompt user
!/usr/bin/expect
set username [lindex $argv 0] set userpass [lindex $argv 1]
spawn htpasswd example $username
interact
HERE IS A REAL WORKING EXAMPLE OF expect helping htpasswd modify the "example" password file - NOTE that "interact" must be at the end of the script!
!/usr/bin/expect
set username [lindex $argv 0] set userpass [lindex $argv 1]
spawn htpasswd example $username
expect "New password:" send $userpass\n
expect "Re-type new password:" send $userpass\n
interact