0

I got this big problem. I have to automate a Telnet connection for this project but I have no idea on how to do that in C/C++ :( . I need to be able to send an ascii file's contents (1 command per line) so that it will automate those commands. Then I need to save the output in a text file, and have the program analyze it. Finally i have to repeat the process automatically for the next ip in line.

If this can be done all automatically already with an exsisting program, could you please direct me to it?

Any help is greatly appreciated!

3
Contributors
2
Replies
4
Views
13 Years
Discussion Span
Last Post by infamous
0

Open winsock on port 23, then just send the data away. Assuming you'll get a reply for every telnet command you send, you can just use blocking winsock commands in a loop.
i.e:

readdata(Filename, CommandArray)
 initwinsock()
 for (int x=0;x<UpperBound(IPList);x++)
 {
 	connect(ip)
 	for (int i=0;i<UpperBound(CommandArray);i++)
 	{
 		 send(CommandArray[i])
 		 recv(RecieveBuffer)
 		 handlebuffer(RecieveBuffer)
 	}
 }
0

you need to make sure u terminate everything u send with "\r\n", or telnet server wont recognize it. and u'll need to login properly, i'd check out part of the telnet RFC, or try and google for a quick telnet tutorial; as well as sniffing your own traffic on a few sessions - that is one of best ways to write a quick prog that actually works. another option, would be to use the Expect scripting language, quite handy for things liek this: http://expect.nist.gov/

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.