I found out how to execute dos commands in C++ and get output in the console window. I connected to a telnet server but I couldn't call telnet commands by doing system(telnetcommand.c_str()); , is there a way to call telnet commands in C++?
I found out how to execute dos commands in C++ and get output in the console window. I connected to a telnet server but I couldn't call telnet commands by doing system(telnetcommand.c_str()); , is there a way to call telnet commands in C++?
#WriteProcessMemory
Short answer: No.
Long answer: Nope.
Longer answer: No, because when you do the system() call that you're doing, you are just spawning another application process. Unless the application that is spawned has a method for inter-process communication (and you fork it - not just make a system call) then there's no way for your app to do anything with it.
In example, a piece of code that calls system("pause"); won't have execution returned to it until the pause process completes. Your code isn't even running while the process that system() called is done.
Edited to add: Also, using system() is inherantly dangerous. What happens when I replace telnet with an application that has viral code strewn throughout it? You just infected your system, but you won't know what caused it.
So there are no ways to do a telnet command in C++? are there any libraries for this? any at all?
#WriteProcessMemory
You would have to write your own telnet-style application. To do this, you'd want to start learning about WinSock, and how to emulate different terminal types if you're going to emulate that functionality - like telnet can.
If you're talking about using the stock telnet application in your OS of choice and making system() calls, then no. It's just not possible, let alone not being adviseable or even remotely sane.
Thanks for the WinSock tutorial!
EDIT: What language is it? C or C++?
Last edited by Gaming; 05-07-2008 at 07:44 PM.
#WriteProcessMemory
Try libwww. It has support for telnet.
it is certainly possible, and not that difficult either.
i have not tested, but, it should work:
- open a pipe for the telnet program
- write telnet commands to the stdin of telnet
good luck!
When I was learning WinSock I found the MSDN step-by-step walk through to be by far the most valuable resource I had. (In fact I ditched all of the tutorials I had even thought of reading because none of them were as good as that MSDN walk through) I'd provide a link but sadly I can't find it ;( (It's a real shame, it was a _really_ good step-by-step.)
"When your work speaks for itself - don't interrupt!"
-Samantha Ingraham.