#! /usr/sgitcl/bin/expect -f # Set timeout to be infinite set timeout -1 # Telnet to zooropa spawn telnet zooropa # Send userid expect login: send bobloblaw\r # Send password expect Password: send ********\r # Get a directory listing expect "zooropa:~#" send ls\r # Get identity expect "zooropa:~#" send whoami\r # Capture user id into a variable expect -re "(.*)\n" set id $expect_out(1,string) # Print out identity send_user "Your identity is: $id \r" # Give control back to user interact