#!/usr/bin/expect -f
set ipaddress [lindex $argv 0]
set src_file  [lindex $argv 1]
set dest_file  [lindex $argv 2]
set run_type  [lindex $argv 3]

set passwd  Dm4ylkj!

set timeout 30

#spawn scp $src_file root@$ipaddress:$dest_file
#expect {
  
#  "yes/no" { send "yes\r";exp_continue }
  
#  "*assword:" { send "$passwd\r" }
  
#}
#expect "100%"
#expect eof

spawn ssh root@$ipaddress
expect {

"yes/no" { send "yes\r";exp_continue }

"*assword:" { send "$passwd\r" }

}

expect "*dama02*"
send "cd /var/www/deploy/\r"
sleep 3
expect "*dama02*"
send "sh deploy4dmpz.sh $run_type\r"
sleep 30
expect "*root*"
send "exit && exit \r"
#sleep 10
#interact
