Telnet router login with applescript
I have to realize a user-based firewall with a draytek vigor 2850 router. Therefore every user has to login at the router during startup with a individual telnet parameter sequence. With the Terminal application the following procedure works fine.
ADCT-iMac:~ Lucky$ telnet 192.168.3.1
Trying 192.168.3.1...
Connected to vigor.router.
Escape character is '^]'.
Account:admin
Password: *********
User login successful, expired time is "Unlimited".
Type ? for command help
> exit
Connection closed by foreign host.
ADCT-iMac:~ Lucky$
I tried the following AppleScript routine with does the job in the background without the Terminal application
set telnet to "telnet 192.168.3.1"
set account to "admin"
set passwd to "xxxxxx"
set resume to "exit"
do shell script telnet
delay 1
do shell script account
delay 1
do shell script passwd
delay 1
do shell script resume
delay 1
Unfortunately it interrupts with the message error "Connection closed by foreign host." number 1 😕
How do I get rid of this error ? Or has anyone a better idea to solve the task ?
Thanks in advance for any useful advice.
Alexander
iMac, Mac OS X (10.6.8), 8GB RAM 27 Display