Solved

How to open a telnet session using C?

Posted on 2003-11-12
11
322 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
 

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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
why debugging a macro i s difficult 10 28
Way to improve it 16 61
Arduino EDI - Programming language 3 80
What is atomic operation? 6 45
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode (http://en.wikipedia.org/wiki/Unicode)? They will have you believe that Unicode requires you to use…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
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.
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now