MCPcopy Create free account
hub / github.com/baidu/tera / ExecuteShellCmd

Function ExecuteShellCmd

src/utils/utils_cmd.cc:101–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101bool ExecuteShellCmd(const std::string& cmd, std::string* ret_str) {
102 char output_buffer[80];
103 FILE* fp = popen(cmd.c_str(), "r");
104 if (!fp) {
105 LOG(ERROR) << "fail to execute cmd: " << cmd;
106 return false;
107 }
108 fgets(output_buffer, sizeof(output_buffer), fp);
109 pclose(fp);
110 if (ret_str) {
111 *ret_str = std::string(output_buffer);
112 }
113 return true;
114}
115
116std::string GetLocalHostAddr() {
117 std::string cmd =

Callers 1

GetLocalHostAddrFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected