Passing arguments to an expect script as variables

# cat test.sh

#!/usr/bin/expect -f
set username [lindex $argv 0]
set password [lindex $argv 1]

spawn ssh $username@HOST
expect “password:”
send “$password\r”
expect “system>”
send “exit\r”

then run :

# ./test.sh root PASSWORD