Link to home
Start Free TrialLog in
Avatar of dssuresh
dssuresh

asked on

a telnet client program ie. how to telnet into a remote (linux ) server using socket at port 23?

I have written a client code which uses socket to connect to port 23 in a remote linux server. But the characters returned by the server are junk.

Whenever anyone telnets into a unix server, he may get the foll. display:

dssuresh@venus:> telnet 160.1.1.30
Trying 160.1.1.30...
Connected to 160.1.1.30.
Escape character is '^]'.

HP-UX hprclass B.11.00 U 9000/800 (t2)

login:


Now, if the user enters login id, then password prompt appears, and if it matches, he is allowed login into the server.

Now my client program should be able to read the above characters and display the login prompt and allow the user to enter and the entered login id should be sent to the server which will reply back with the passwd prompt. In effect, I would like to write a client program which allows a user to remote login into a machine(at port 23).

A general client program trying to connect to remote server at port 23 only returns junk characters. How to solve this problem? Any code?

ASKER CERTIFIED SOLUTION
Avatar of ahoffmann
ahoffmann
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kiffney
kiffney

If you just want to automate a telnet login and get some data, you could sidestep all this by scripting telnet.  Look for 'expect', which is built upon tcl.  If you write an expect script, you can make telnet do what you like - log in, get data, whatever.  There is an O'Reilly book on Expect that's very good - written by Expect's author.  
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: ahoffmann {http:#6464971} & bryanh {http:#6468992}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
sounds fine to me - I didn't see that ahoffman had mentioned 'expect' which is probably what dssuresh needed lo, these many moons ago.