Passing arguments to an expect script as variables

# cat

#!/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 :

# ./ root PASSWORD

Leave a Reply

Your email address will not be published. Required fields are marked *


This site uses Akismet to reduce spam. Learn how your comment data is processed.