1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| #!/usr/bin/expect
stty -echo
send_user -- "Who are you ? "
expect_user -re "(.*)\n"
send_user "\n"
stty echo
set USER $expect_out(1,string)
stty -echo
send_user -- "Give me the password for $USER: "
expect_user -re "(.*)\n"
send_user "\n"
stty echo
set PWD $expect_out(1,string)
stty -echo
send_user -- "Now give me the password for the system user of the database:"
expect_user -re "(.*)\n"
send_user "\n"
stty echo
set ORACLE_PASS $expect_out(1,string)
spawn ssh -t ${USER}@ip1 ssh -t ${USER}@ip2 sudo su - oracle /path/to/my/script/export_db.sh $ORACLE_PASS
#system ssh -t ${USER}@ip1 ssh -t ${USER}@ip2 sudo su - oracle /path/to/my/script/export_db.sh $ORACLE_PASS
#use correct prompt
set prompt ":|#|\\\$"
expect "password:"
send "$PWD\r"
expect "Enter passphrase for key"
send "$PWD\r"
expect "password for $USER:"
send "$PWD\r" |
Partager