gim@xps13:~/pc-settings/bincp$ cat mycli-conn.expect 
set timeout -1

set pwd_ad $env(PWD_AD)
set pwd_db $env(PWD_DB_FINANCE_APP)

set apphost [lindex $argv 0]
set ssh_tnl_port [lindex $argv 1]
set mysql_tnl_port [lindex $argv 2]
set mysql_host [lindex $argv 3]
set dbuser [lindex $argv 4]
set dbhost [lindex $argv 5]
set dbport [lindex $argv 6]
set dbname [lindex $argv 7]
set logfile [lindex $argv 8]

spawn ssh -oStrictHostKeyChecking=no -f bok@gw.my.net -L${ssh_tnl_port}:${apphost}:22 sleep 10
expect "bok@aws-gw"
send "$pwd_ad\r"
sleep 1

spawn ssh -oStrictHostKeyChecking=no -f -p${ssh_tnl_port} bok@localhost.fin -L${mysql_tnl_port}:${mysql_host}:3306 sleep 10
expect "bok@"
send "$pwd_ad\r"
sleep 1

spawn ~/bincp/mycli-with-log.sh $dbuser $dbhost $dbport $dbname $logfile
expect "Password"
send "$pwd_db\r"

interact


-- gim 2021-02-21 19:11:38
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-21 19:11:38
Processing time 0.0054 sec