i want to write a simple code that can let me to telnet and connect to my modem
so i wrote the code below but when cmd run it tell me telnet its not a external or bath command but i can access to telnet when i use cmd normally
It seems it cannot find the binary. Are you sure the telnet client is in your PATH environment variable of your program? Try printing it with after finding the content of the variable using getenv.
You can also try calling system with start telnet, this could solve the problem in some cases.
Allow me to ask a stupid question, is telnet installed on your system? For a number of versions now you would have to go to "Control Panel" -> "Turn Windows Features on or off" and unpack it before you could use it.
What do you plan on doing with this by the way? "system()" doesn't give you anything back to interact with the telnet console once you call it. It will just pop-up in a new Windows and your program will sit there waiting for it to time out.
yes as i said i can easily access to telent when i am using cmd normally (WINDOWS + RUN using cmd that way) but my program say telnet is not a batch or command
actuly i am training my c++ skills so my codes doesnt follow any goal right now i want to write a program that user to connect to her or his modem another cmd should pop up and let user insert username and password juts like what telnet normally do but program cant find telnet
I wouldn't recommend this solution. Copying the file over might solve the problem on your machine, but on others it might not (it might complain about missing DLL's, if your telnet client requires them). I'd either advice creating a BATCH script in your project files that calls the telnet client. e.g:
telnet_redirect.bat:
telnet %*
Then calling this batch file from your original program. Another (more straightforward) solution is to just specify the entire path in your system call:
u r totally right sir right now i faced another problem its only working on my machine
the code that u gave me cant find the telnet because the c++ cmd is running in shell mode so he know himself as C:\ so he cant find user dir
Is the telnet client set up on the other machine you are running on? If not, you should enable it in the control panel -> programs and features -> turn windows features on or off. Then checking the telnet client. Without the features enabled the program will not be visible in your system directory and your program will not be able to find it.
As an amendment to the post from Shadowwolf, you need telnet server installed on the target with the corresponding service running in the background and the appropriate port open on the targets firewall.