-
Notifications
You must be signed in to change notification settings - Fork 0
/
pan_cli.exp
94 lines (68 loc) · 1.34 KB
/
pan_cli.exp
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/expect -f
#
# [2022070901]
#
#set uname [lindex $argv 0]
#set pass [lindex $argv 1]
#set host [lindex $argv 2]
set uname "admin"
set pass "admin"
set host [lindex $argv 0]
set prompt "> $"
set cli_file "cli.txt"
set time_delay 120
set time_interval 30
set intervals 6
# set time_delay 20
# set time_interval 20
# set intervals 18
#
#
#
log_user 1
set mypid [pid]
#log_file cli.log
log_file -noappend "cli-$mypid.log"
spawn /usr/bin/ssh -o StrictHostKeyChecking=no -l $uname $host
expect {
"Password: " {
sleep 1
send "$pass\r"
} timeout {send_user "error"}
}
set timeout 5
expect -re $prompt
send "set cli pager off\r"
expect -re $prompt
send "show system info\r"
# expect -re $prompt
# send "debug dataplane fpga state\r"
# expect -re $prompt
# send "show system setting ctd-mode\r"
sleep $time_delay
set count $intervals
set f [open "$cli_file"]
set commands [split [read $f] "\n"]
close $f
while {$count > 0} {
foreach command $commands {
expect -re $prompt
send "$command\r"
}
set count [expr $count-1]
sleep $time_interval
}
#expect -re $prompt
#send "request tech-support dump\r"
#expect -re $prompt
#send "show interface all\r"
#expect -re $prompt
#send "show running tunnel flow all filter type ipsec\r"
expect -re $prompt
send "exit\r"
#
#
#
puts "CLI session captured and saved in cli-$mypid.log"
exit
# End