The script simply named t.sh:
[root@jarvis ~]# cat /usr/local/bin/t.sh
#!/usr/bin/expect
# grab the IP
set echo off
set arg1 [lindex $argv 0]
spawn telnet $arg1
#send “ “
expect *
send “username\r”
expect “Password: “
send “UserPassword\r”
expect *
send “show int status\r”
send ” \r”
#expect ”>“
interact
This script, among others can be customized with different cli commands to be issued once you're logged in in the switch.
Alias to be created in .bashrc: alias t='/usr/local/bin/t.sh'