Posted to tcl by Roland- at Thu Apr 16 19:21:13 GMT 2020view raw
- #!/usr/bin/expect -f
- set timeout 20
- set IPaddress someip
- set Username zabbix
- set Password temp for testing
- log_file -noappend /srv/data/conn.txt
- spawn ssh -o "StrictHostKeyChecking no" $Username@$IPaddress
- expect "*assword: "
- send "$Password\r"
- expect "#"
- send "show vpn-sessiondb anyconnect filter protocol dtlstunnel | grep -C Username \r"
- expect "Number"
- scan "Number of lines which match regexp = 30" "Number of lines which match regexp = $d"
- send "exit\r"
- sleep 1
- send_log /srv/data/conn.txt
- exit