8 #include <std_msgs/String.h> 10 #include <clover/Execute.h> 15 bool handle(clover::Execute::Request& req, clover::Execute::Response& res)
17 ROS_INFO(
"Execute: %s", req.cmd.c_str());
19 std::array<char, 128>
buffer;
22 FILE *fp = popen(req.cmd.c_str(),
"r");
25 res.code = clover::Execute::Request::CODE_FAIL;
26 res.output =
"popen() failed";
30 while (fgets(buffer.data(), buffer.size(), fp) !=
nullptr) {
31 res.output += buffer.data();
34 res.code = pclose(fp);
39 int main(
int argc,
char **argv)
bool handle(clover::Execute::Request &req, clover::Execute::Response &res)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
int main(int argc, char **argv)