Jak zautomatyzować sesję telnet przy użyciu Oczekiwanie?

Próbuję napisać oczekiwany skrypt do automatyzacji telnetu. To jest to, co mam do tej pory.

#!/usr/bin/expect
# Test expect script to telnet.

spawn telnet 10.62.136.252
expect "foobox login:"
send "foo1\r"
expect "Password:"
send "foo2\r"
send "echo HELLO WORLD\r"
# end of expect script.

Zasadniczo chcę zrobić telnet na następujący adres IP, a następnie echo HELLO WORLD. Jednak wydaje się, że skrypt nie działa po próbie telnetu ... Nie jestem pewien, czy jest w stanie zaakceptować dane logowania i hasła, ale nie jest to echo HELLO WORLD. Zamiast tego otrzymuję to wyjście:

cheungj@sfgpws30:~/justin> ./hpuxrama 
spawn telnet 10.62.136.252
Trying 10.62.136.252...
Connected to 10.62.136.252.
Escape character is '^]'.
Welcome to openSUSE 11.1 - Kernel 2.6.27.7-9-pae (7).

foobox login: foo1
Password: foo2~/justin> 

questionAnswers(4)

yourAnswerToTheQuestion