执行shell脚本获取返回值字符串
std::string executeShellCommand(const std::string &command)
{
FILE* pipe = popen(command.c_str(), "r");
if (!pipe) return "ERROR";
char buffer[128];
std::string result = "";
while(!feof(pipe))
{
if(fgets(buffer, 128, pipe) != nullptr)
result += buffer;
}
pclose(pipe);
return result;
}