| 50 | } |
| 51 | |
| 52 | int OHDUtil::run_command(const std::string& command, |
| 53 | const std::vector<std::string>& args, |
| 54 | bool print_debug) { |
| 55 | const auto command_with_args = create_command_with_args(command, args); |
| 56 | if (print_debug) { |
| 57 | openhd::log::get_default()->debug("run command begin [{}]", |
| 58 | command_with_args); |
| 59 | } |
| 60 | // https://man7.org/linux/man-pages/man3/system.3.html |
| 61 | const auto ret = std::system(command_with_args.c_str()); |
| 62 | // openhd::log::get_default()->debug("return code:{}",ret); |
| 63 | if (ret < 0) { |
| 64 | openhd::log::get_default()->warn("Invalid command, return code {}", ret); |
| 65 | } |
| 66 | return ret; |
| 67 | } |
| 68 | |
| 69 | std::optional<std::string> OHDUtil::run_command_out(const std::string& command, |
| 70 | const bool debug) { |