TEXT   103
asa show version
Guest on 16th March 2023 12:12:21 AM


  1. #!/usr/bin/expect -f
  2.  
  3. set ip [lindex $argv 0]
  4. set pass [lindex $argv 1]
  5. set enable [lindex $argv 2]
  6.  
  7.  
  8. set force_conservative 0 ;# set to 1 to force conservative mode even if
  9. ;# script wasn't run conservatively originally
  10. if {$force_conservative} {
  11. set send_slow {1 .1}
  12. proc send {ignore arg} {
  13. sleep .1
  14. exp_send -s -- $arg
  15. }
  16. }
  17.  
  18. set timeout -1
  19. spawn $env(SHELL)
  20. match_max 100000
  21.  
  22. send -- "ssh pix@$ip\r"
  23.  
  24. expect "assword:"
  25.  
  26. send -- "$pass\r"
  27.  
  28.  
  29. expect "Type help or '?' for a list of available commands."
  30.  
  31. send -- "enable\r"
  32. expect -exact "enable\r
  33. Password: "
  34.  
  35. send -- "$enable\r"
  36.  
  37. send -- "show run hostname\r"
  38. expect "#"
  39.  
  40. send -- "show version | grep Serial\r"
  41. #send -- "\r"
  42. expect "Serial"
  43. #sleep 1
  44.  
  45. send -- "show version | grep Hardware\r"
  46. #send -- "\r"
  47. expect "Hardware"
  48. #sleep 1
  49.  
  50. send -- "exit\r"
  51. #send -- "exit\r"

Raw Paste

Login or Register to edit or fork this paste. It's free.