Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ShowUsage()
- {
- cout<<"Usage 1 (arguments):\n\t Example IP Port Username Password [SleepIntervalSecond]"<<endl;
- cout<<"Usage 2 (stdin):\n\t Example "<<endl;
- }
- int main(int argc, char* argv[])
- {
- string IP, UserName, Password;
- unsigned short Port = 0;
- int SleepIntervalSecond = 20;
- if(argc == 1)
- {
- cerr << "IP:";
- cin >> IP;
- cerr << "Port:";
- cin >> Port;
- cerr << "UserName:";
- cin >> UserName;
- cerr << "Password:";
- cin >> Password;
- cerr << "SleepIntervalSecond:";
- cin >> SleepIntervalSecond;
- }
- else if (argc > 4)
- {
- IP = argv[1];
- Port = atoi(argv[2]);
- UserName = argv[3];
- Password = argv[4];
- if (argc > 5)
- {
- SleepIntervalSecond = atoi(argv[5]);
- }
- }
- else
- {
- ShowUsage();
- exit(0);
- }
- cout << "====================" <<endl;
- cout << " IP:" << IP.c_str() <<endl;
- cout << "PORT:" << Port <<endl;
- cout << "USER:" << UserName.c_str() <<endl;
- cout << "PASS:" << Password.c_str() <<endl;
- cout << "INTERVAL:" << SleepIntervalSecond << "s" <<endl;
- cout << "====================" <<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement