aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/remote_excute.exp
blob: ac901353ea8f8eec822c5308fe9deba31ed15243 (plain)
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
30
31
32
33
34
35
#!/usr/bin/expect

set addr [lindex $argv 0]
set user [lindex $argv 1]
set passwd [lindex $argv 2]
set command [lindex $argv 3]
set cmd_prompt "]#|~]?"

eval spawn ssh $user@$addr
set timeout 60

expect {
    -re ".*es.*o.*"
    {
        exp_send "yes\r"
        exp_continue
    }

    -re ".*sword:" {
        exp_send "$passwd\r"
        exp_continue
    }
    -re $cmd_prompt {
        exp_send "$command\r"
    }
}

exec sleep 1

expect {
    -re $cmd_prompt {
        send "exit\r"
    }
}
send "exit 1\r"