Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static bool getIdOf(const std::string& owner, const std::string pattern, id_t& id)
- {
- Popen3 pr("id", {owner});
- pr.run(true);
- int exitCode = pr.wait();
- if (exitCode) {
- std::cerr << "ERROR code: " << exitCode << ", Output was: " << pr.stdOutAndStdErr();
- return false;
- }
- auto output = pr.stdOut();
- std::regex rgx(pattern);
- std::smatch match;
- if (std::regex_search(output, match, rgx)) {
- id = atol(match.str(1).c_str());
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement