1836355 Members
2154 Online
110100 Solutions
New Discussion

telnet

 
fazly
Occasional Contributor

telnet

hi, i try run my switch(d-link) on bash script but it fail.My username and password are correct.The error appear like this :


DES-3326SR Fast Ethernet Switch Command Line Interface

Firmware: Build 4.03-B01
Copyright(C) 2000-2005 D-Link Corporation. All rights reserved.
UserName:fazly
PassWord:*******
Fail!
UserName:Connection closed by foreign host.

what shoul i do?
5 REPLIES 5
skt_skt
Honored Contributor

Re: telnet

The error looks like an authentication failure.
what you mean "run my switch on bash script"?
fazly
Occasional Contributor

Re: telnet

i mean i build coding in bash script (shell script) and it appear in terminal something like this:


DES-3326SR Fast Ethernet SwitCommand Line Interface
Copyright(C) 2000-2005 D-Link Corporation. All rights reserved.
UserName:fazly
PassWord:*******
DES-3326SR:4#
in my terminal it success but in shell script it fail. Why? so here this is my coding in shell script.





host=10.90.90.90
port=23
UserName=fazly
PassWord=cat

(echo open ${host} ${port}
sleep 1
echo ${UserName}
sleep 1
echo ${PassWord}
sleep 1
echo exit) | telnet


Dennis Handly
Acclaimed Contributor

Re: telnet

I'm not sure if your sleep is long enough?

Typically you use expect to script this.
Or for ftp, you put the user and password on the same line, and use -n.
Rasheed Tamton
Honored Contributor

Re: telnet

Hi,

Try increasing your sleep time more. Especially the first sleep.
From sleep 1 to sleep 3 , etc. If it is a slow connection you will have to increase accordingly. Play with the sleep then might be ok if you do not want to use expect script.

Steven Schweda
Honored Contributor

Re: telnet

> Typically you use expect to script this.

Or Kermit, which has nice scripting features.

http://www.columbia.edu/kermit/
http://www.columbia.edu/kermit/scriptlib.html
http://www.columbia.edu/kermit/ckscripts.html