#!/usr/bin/expect spawn telnet samsung.router 30023 expect "login:" exp_send "root\r" expect "Password:" exp_send "banana\r" expect "# " exp_send "ifconfig | grep \"P-t-P\" | cut -c 21-36 | cut -f1 -d \" \"\r\r >" expect "# " exp_send "exit\r"