Windows下:獲取cmd命令返回結果
linux下:
int systemex(const char* cmdstring, string &info)
{
if (cmdstring == NULL || cmdstring[0] == 0)
return EINVAL;
FILE *fd = popen(cmdstring, "r");
if (fd != NULL)
{
char buf[1024];
while (fgets(buf, 1024, fd))
{
info += buf;
}
pclose(fd);
}
else
{
Log(strerror(errno), "popen");
return errno;;
}
return 0;
}