#!/usr/bin/expect set timeout 10 log_user 0 spawn ssh 1.1.1.1 expect "?*" send "show sessions\r" log_user 1 expect "?*" send "exit\r"