[nzlug] Telnet in all it's... hmm.... greatness?

Jim Cheetham jim at gonzul.net
Tue Jun 10 11:11:27 NZST 2008


On Tue, Jun 10, 2008 at 10:51 AM, Nevyn <nevynh at gmail.com> wrote:
>
> (
>  sleep 1
>  echo username
>  sleep 1
>  echo password
>  sleep 1
>  commandToTryAndStartPPP
>  sleep 10
>  echo logout

sample (untested) code in expect ...
see http://en.wikipedia.org/wiki/Expect and the rest of the Internet
for more details
--------------------
#!/usr/bin/expect -f
exp_internal 0
log_user 0
set timeout 5

set username "fred"
set password "letmein"
set ipaddress 10.0.0.10

spawn telnet $ipaddress

expect {
     "login:" {send "$username\r"}
     timeout {exit 1}
}

expect "password:"
send "$password\r"

expect "prompt>"
send "is ppp up?"
expect {
      "yes it is" {exit 0}
      "no it isnt" {send "well start it then\r"}
}

send "exit\r"

--------------------

-jim



More information about the NZLUG mailing list