Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Programming of the Telnet protocol

Posted on 1997-11-21
7
Medium Priority
?
243 Views
Last Modified: 2013-12-26
Dear all,

  I would like to write a program to telnet to another server.  However, I don't know what the command sequence is.
For example, when I can connect to the server with the port 23, then what command I will receive and what command I should send so that I can receive the 'login: " prompt?

Thanks!

Benson
0
Comment
Question by:benson031397
7 Comments
 
LVL 1

Expert Comment

by:dhughes111797
ID: 1295672
The machine on the other end must be running a telnet daemon program. This is a program that listens for a connection and
then exchanges some setup parameters with the client program that you run. When it authenticates you against the remote machine, it passes off the connection to a shell.

Most of the time, telnetd is run from a program called inetd. Take a look at the process table of the remote system and see if inetd is running. The file /etc/inetd.conf has the information about what daemons are run, and usually one of the linese in there is for telnetd.  It is perfectly reasonable for a site
to disable telnetd for security reasons - (plain text passwords
are a security risk)

If you do not receive a login prompt, and instead get something
like 'connection refused' when telneting to a remote machine,
then telnetd has been disabled on that machine. You do not
need to give a special port number to get the default behavior.

0
 

Author Comment

by:benson031397
ID: 1295673
The telnetd is absolutely enabled as I can type telnet to that server.  But now I think I have sent wrong init command sequence.
Can any experts give me the right init command sequence?
0
 
LVL 1

Expert Comment

by:dhughes111797
ID: 1295674
It would help if you supply OS information (name and revision)
and possibly hardware type if applicable.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:benson031397
ID: 1295675
Do u know what is telnet protocol?  My question is that what the init command sequences I will receive or should send after connecting the any unix server(with the daemon or protocol of telnet) with the port of 23.  I think the telnet protocol is independent of what the version of OS or name.  It just depends on whether the OS will use telnet protocol or not to receive the telnet request.


Thanks!
0
 

Accepted Solution

by:
philipm earned 30 total points
ID: 1295676
while many client/server programmers will tell you to use the LWP module in perl for such a thing, I recommend using Expect, a language based on Tcl/Tk for doing such things (ftp, telnet http).  It is very easy to use.  The best and quickest way to become familiar with Expect is to read the inventor of Expect's book on the language which is available on O'Reilly.

Here is an example program:

#!/usr/local/bin/expect --
spawn telnet netcom.com
expect "ogin:"
send "your_login\r"
expect "assword:"
send "your_password\r"
expect ">"
interact

This will open the telnet program to connect to netcom.com. Then it will wait for the appropriate strings and send the correct responses. The command 'interact' gives control back to the user.

You would want to make sure the response strings work for the server you are connected too for it too work properly.  

The main reason Expect is so useful is that it can be programmed to respond to a variety of responses, and it can have a timeout set to only let a query attempt run for so long

0
 

Author Comment

by:benson031397
ID: 1295677
Dear sir,

 It is a good answer.  But I want to do it by using socket programming becasue I would like to use Java or C to implement the telnet protocol

thanks!
Benson
0
 

Expert Comment

by:happynetguy
ID: 1295678
I think you should read the RFCs about telnet protocol carefully.
Or you can read the telnet souce code of Linux.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Screencast - Getting to Know the Pipeline

879 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question