cant use telnet in my source

HI ALL!

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

TNX FOR HELP ANYWAY!
 
   system("telnet 192.168.1.1");
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.
Last edited on
no i actully didnt add any telnet clinet INSIDE MY PATH enviroment where can i find that path and how i can add it?
dir telnet.exe /s
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.
Last edited on
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
ok i found the solution!

if u wanted to do this for any reason! first go to this directory and copy telnet.exe

C:\Windows\System32\telnet.exe

then come back to your project files and paste it into your project

C:\Users\USERNAME\Documents\Visual Studio 2013\Projects\YOUR PROJECT NAME\YOUR PROJECT NAME

for sample mines is

C:\Users\merdasss\Documents\Visual Studio 2013\Projects\training\training

telent well lose its friendly(!) envoroment and can only be accesseble from calling it from your source for example

system("telnet 192.168.1.1");

tnx for help everybody! =)
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:

 
system("C:\\Windows\\System32\\telnet.exe *other parameters*");
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

can someone please help please?
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.
Last edited on
Topic archived. No new replies allowed.