#include<bits/stdc++.h>
int main(int argc, char const *argv[])
{
std::string host, message = "";
if(argc > 2)
{
if(strcmp(argv[1], "-host") == 0)
{
host = argv[2];
if(strcmp(argv[3], "-msg") == 0)
{
for(int i = 4; i < argc; i++)
message = message + argv[i];
}
else
{
printf("%s [-host host -msg message]\n -host host:who need this message\n -msg message:what message do you need send", argv[0]);
return 0;
}
}
else
{
printf("%s [-host host -msg message]\n -host host:who need this message\n -msg message:what message do you need send", argv[0]);
return 0;
}
}
else
{
printf("HOST:");
std::cin >> host;
printf("MESSAGE:");
std::cin >> message;
}
system(("msg /server:" + host + " * \"" + message + "\"").c_str());
}
发送消息的程序,HOST可以是IP或主机名