mero42
06-24-2005, 06:39 PM
Hi. I haven't seen many questions like this, so I don't even know if it is possible to do the following:
I am writing a program that will connect to another machine (my Direcway cable modem) and restart it without the user actually entering any text. Using
system("telnet 192.168.0.1 1953"); works just fine, but how would I get the program to enter a string of text (rr) that reboots the modem? And afterwards, how would the program revert out of telnet to display all the "you have succesfully rebooted your modem" messages?
Here is the code I have so far:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(){
std::cout<<"Welcome to the Direcway Restart Program" <<endl;
std::cout<<"-----------------------------------------" << endl;
char User_Choice;
std::cout<<"Would you like to restart your Direcway terminal? (Y, N)" <<endl;
std::cin>>User_Choice;
if (User_Choice =='Y') {
std::cout<<"Restarting your Direcway Terminal..." <<endl;
system("telnet 192.168.0.1 1953");
std::cout<<"You have succesfully restarted your Direcway Terminal" <<endl;
system("PAUSE");
}
else if (User_Choice =='N') {
cout<<"Ok. Exiting Program." <<endl;
system("PAUSE");
}
else if (User_Choice != 'Y' || 'N'){
std::cout<<"Fatal error. Exiting program. Please enter either \"Y\" or \"N\" next time. "<<endl;
system("PAUSE");
}
}
I hope someone can help... :thumbsup:
I am writing a program that will connect to another machine (my Direcway cable modem) and restart it without the user actually entering any text. Using
system("telnet 192.168.0.1 1953"); works just fine, but how would I get the program to enter a string of text (rr) that reboots the modem? And afterwards, how would the program revert out of telnet to display all the "you have succesfully rebooted your modem" messages?
Here is the code I have so far:
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(){
std::cout<<"Welcome to the Direcway Restart Program" <<endl;
std::cout<<"-----------------------------------------" << endl;
char User_Choice;
std::cout<<"Would you like to restart your Direcway terminal? (Y, N)" <<endl;
std::cin>>User_Choice;
if (User_Choice =='Y') {
std::cout<<"Restarting your Direcway Terminal..." <<endl;
system("telnet 192.168.0.1 1953");
std::cout<<"You have succesfully restarted your Direcway Terminal" <<endl;
system("PAUSE");
}
else if (User_Choice =='N') {
cout<<"Ok. Exiting Program." <<endl;
system("PAUSE");
}
else if (User_Choice != 'Y' || 'N'){
std::cout<<"Fatal error. Exiting program. Please enter either \"Y\" or \"N\" next time. "<<endl;
system("PAUSE");
}
}
I hope someone can help... :thumbsup: