!/usr/bin/expect
REMEMBER, the first SSH connection has a yes/no to store the remote certificate
scripting normal interaction: ssh user@address 'df -h' , don't show anything but the output
log_user 0
set timeout 1 set username [lindex $argv 0] set userpass [lindex $argv 1] set remoteaddress 10.10.10.240 set command "df -h"
if { $argc < 2 } { puts "Wrong number of parameters, usage: script username password" exit }
spawn ssh $username@$remoteaddress $command
expect "$username@$remoteaddress's password: "
send "$userpass\n"
interact
!/usr/bin/expect
log_user 0 set timeout 1 set username [lindex $argv 0] set userpass [lindex $argv 1] set remoteaddress 10.10.10.240 set command "vim-cmd vmsvc/getallvms | grep -i 'QA' | cut -f 1 -d ' '"
if { $argc < 2 } { puts "Wrong number of parameters, usage: script username password" exit }
spawn ssh $username@$remoteaddress $command expect "$username@$remoteaddress's password: " send "$userpass\n" interact