Solved

Programming of the Telnet protocol

Posted on 1997-11-21
7
236 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maxBlock challenge 30 128
ShiftLeft challenge 21 80
Change to event 1 111
Way to decrease size of apk file 9 65
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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

776 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