Posted to tcl by schelte at Fri Mar 21 21:52:07 GMT 2014view raw

  1. # Functions
  2. proc save_output {varname} {
  3. upvar 1 $varname var
  4. set var ""
  5. expect {
  6. -re {.*#$} {
  7. append var $expect_out(buffer)
  8. }
  9. full_buffer {
  10. append var $expect_out(buffer)
  11. exp_continue
  12. }
  13. }
  14. }
  15.  
  16. # Login and get rid of buffer length
  17. spawn ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no $user@$host
  18. expect "*assword*"
  19. send "$pass\r"
  20. expect $prompt
  21. send "terminal length 0\r"
  22.  
  23. expect $prompt
  24. send "show ver\r"
  25. save_output shver
  26. puts "\n\n\n $shver"
  27.