Skip to content

Instantly share code, notes, and snippets.

@varvaruc
Created December 2, 2019 14:09
Show Gist options
  • Save varvaruc/108d915fe8bc63831bac43ca4172b5cf to your computer and use it in GitHub Desktop.
Save varvaruc/108d915fe8bc63831bac43ca4172b5cf to your computer and use it in GitHub Desktop.
std::string HttpServer::getStdoutFromCmd(std::string cmd)
{
std::string data;
char buffer[BUFSIZ];
FILE *stream = popen(cmd.c_str(), "r");
while (fgets(buffer, BUFSIZ, stream) != NULL )
data.append(buffer);
pclose(stream);
return data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment