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

#   Functions
proc save_output {varname} {
    upvar 1 $varname var
    set var ""
    expect {
        -re {.*#$} {
            append var $expect_out(buffer)
        }
        full_buffer {
            append var $expect_out(buffer)
            exp_continue
        }
    }
}

#   Login and get rid of buffer length
spawn ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no $user@$host
expect "*assword*"
send "$pass\r"
expect $prompt
send "terminal length 0\r"

expect $prompt
send "show ver\r"
save_output shver
puts "\n\n\n $shver"