#!/usr/bin/expect
set timeout 60
spawn ssh [lindex $argv 1]@[lindex $argv 0]
expect "*?assword" {
send "[lindex $argv 2]\r"
}
expect ":~$ " {
send "
mkdir -p /home/tools/baeldung/auto-test;
cd /home/tools/baeldung/auto-test;
tree
sshpass -p 'Baels@123' scp -r tools@10.45.67.11:/home/tools/cw/baeldung/get_host_info.sh ./;
tree
bash get_host_info.sh\r"
}
expect ":~$ " {
send "exit\r"
}
expect eof