Posted to tcl by Roland- at Thu Apr 16 19:21:13 GMT 2020view raw

  1. #!/usr/bin/expect -f
  2. set timeout 20
  3. set IPaddress someip
  4. set Username zabbix
  5. set Password temp for testing
  6. log_file -noappend /srv/data/conn.txt
  7. spawn ssh -o "StrictHostKeyChecking no" $Username@$IPaddress
  8. expect "*assword: "
  9. send "$Password\r"
  10. expect "#"
  11. send "show vpn-sessiondb anyconnect filter protocol dtlstunnel | grep -C Username \r"
  12. expect "Number"
  13. scan "Number of lines which match regexp = 30" "Number of lines which match regexp = $d"
  14. send "exit\r"
  15. sleep 1
  16. send_log /srv/data/conn.txt
  17. exit
  18.