Solved

How to open a telnet session using C?

Posted on 2003-11-12
11
331 Views
Last Modified: 2008-02-26
In Perl, I learned to use the Net::Telnet module. It includes the following commands: login, waitfor, print cmd, close.

Is there a telnet library in C with the equivalent commands? How do I use them?
0
Comment
Question by:elvin226
  • 4
  • 3
  • 2
11 Comments
 
LVL 8

Expert Comment

by:ssnkumar
ID: 9737536
For doing this in C, you will have to write your own code using socket programming.
The commands you will be using are socket(), bind(), listen(), accept(), send() and receive().
So, the first thing is to learn socket programming!:-)
But, both windows and Unix provide telnet program. Why don't you use this itself!?

In C, you can call telnet using the following statement: system("telnet ip_addr");
Or you can use exec() to do the same.

Hope I answered your question....
0
 
LVL 8

Assisted Solution

by:ssnkumar
ssnkumar earned 150 total points
ID: 9737563
For doing this in C, you will have to write your own code using socket programming.
The commands you will be using are socket(), bind(), listen(), accept(), send() and receive().
So, the first thing is to learn socket programming!:-)
But, both windows and Unix provide telnet program. Why don't you use this itself!?

In C, you can call telnet using the following statement: system("telnet ip_addr");
Or you can use exec() to do the same.

Hope I answered your question....
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 150 total points
ID: 9737564
A seesion can be initiated with
system ( "telnet ... ");
or by
fork()
followed by exec()....

for full library, have a look at TCPware
http://vms.process.com/ftp/tcpware/documentation/html/programmer/httoc.htm
0
Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

 

Author Comment

by:elvin226
ID: 9745069
What I'm trying to do is an automated telnet script, not interactive, so I can't use system("telnet"). The program will be the one to send messages, not the user, and it has to wait for the remote machine's response before sending another message.
0
 
LVL 8

Expert Comment

by:ssnkumar
ID: 9745116
If you want a interactive telnet session, then you will have to write the complete program!
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9745364
download the telent library ... it provides the API do the work ...
If you wish to do it with script, then use expect
http://expect.nist.gov/

using them, you wont have to write the whle code
0
 

Author Comment

by:elvin226
ID: 9745452
sunnycoder,

what I'm asking for is the C library for telnet and examples of how to use it's functions...if there exists one.

I've already done it with Perl, now I want to learn how to do it in C.
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 9745583
take a look at any telent client coded in C
http://www.sofotex.com/download/Networking/Telnet/more3.html
http://linux.tucows.com/preview/220521.html
http://www.ararat.cz/synapse/

you would be having one with your own linux distribution too !!! tucows site has lots of clients ... search it for more info
0
 
LVL 8

Expert Comment

by:ssnkumar
ID: 10400537
I too deserve points!:-))

-ssnkumar
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

821 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