42 if (config.
check(
"cmd") && config.
check(
"stdio"))
48 Help(
"SYNTAX ERROR: missing remote stdio server\n");
53 Help(
"SYNTAX ERROR: missing command\n");
58 Help(
"SYNTAX ERROR: missing tag\n");
63 Help(
"SYNTAX ERROR: missing remote server\n");
69 printf(
"*********** %s ************\n", config.
toString().c_str());
77 if (config.
check(
"workdir")) {
80 if (config.
check(
"geometry")) {
83 if (config.
check(
"hold")) {
86 if (config.
check(
"env")) {
89 if (config.
check(
"log")) {
105 if (!response.
size()) {
118 if (config.
check(
"cmd"))
124 Help(
"SYNTAX ERROR: missing command\n");
129 Help(
"SYNTAX ERROR: missing tag\n");
134 Help(
"SYNTAX ERROR: missing remote server\n");
144 if (config.
check(
"workdir")) {
147 if (config.
check(
"log")) {
158 if (config.
check(
"env")) {
164 if (!response.
size()) {
180 if (config.
check(
"kill"))
184 Help(
"SYNTAX ERROR: missing remote server\n");
189 Help(
"SYNTAX ERROR: missing tag\n");
194 Help(
"SYNTAX ERROR: missing signum\n");
206 if (config.
check(
"sigterm"))
210 Help(
"SYNTAX ERROR: missing tag");
215 Help(
"SYNTAX ERROR: missing remote server\n");
226 if (config.
check(
"sigtermall"))
230 Help(
"SYNTAX ERROR: missing remote server\n");
240 if (config.
check(
"ps"))
244 Help(
"SYNTAX ERROR: missing remote server\n");
248 std::vector<processInfo> processes;
255 if (config.
check(
"isrunning"))
259 Help(
"SYNTAX ERROR: missing remote server\n");
265 Help(
"SYNTAX ERROR: missing tag\n");
276 if (config.
check(
"sysinfo"))
280 Help(
"SYNTAX ERROR: missing remote server\n");
288 fprintf(stdout,
"No response. (timeout)\n");
292 fprintf(stdout,
"Platform name : %s\n",
info.platform.name.c_str());
293 fprintf(stdout,
"Platform dist : %s\n",
info.platform.distribution.c_str());
294 fprintf(stdout,
"Platform release : %s\n",
info.platform.release.c_str());
295 fprintf(stdout,
"Platform code : %s\n",
info.platform.codename.c_str());
296 fprintf(stdout,
"Platform kernel : %s\n\n",
info.platform.kernel.c_str());
298 fprintf(stdout,
"User Id : %d\n",
info.user.userID);
299 fprintf(stdout,
"User name : %s\n",
info.user.userName.c_str());
300 fprintf(stdout,
"User real name : %s\n",
info.user.realName.c_str());
301 fprintf(stdout,
"User home dir : %s\n\n",
info.user.homeDir.c_str());
303 fprintf(stdout,
"Cpu load Ins.: %d\n",
info.load.cpuLoadInstant);
304 fprintf(stdout,
"Cpu load 1 : %.2lf\n",
info.load.cpuLoad1);
305 fprintf(stdout,
"Cpu load 5 : %.2lf\n",
info.load.cpuLoad5);
306 fprintf(stdout,
"Cpu load 15 : %.2lf\n\n",
info.load.cpuLoad15);
308 fprintf(stdout,
"Memory total : %dM\n",
info.memory.totalSpace);
309 fprintf(stdout,
"Memory free : %dM\n\n",
info.memory.freeSpace);
311 fprintf(stdout,
"Storage total : %dM\n",
info.storage.totalSpace);
312 fprintf(stdout,
"Storage free : %dM\n\n",
info.storage.freeSpace);
314 fprintf(stdout,
"Processor model : %s\n",
info.processor.model.c_str());
315 fprintf(stdout,
"Processor model num : %d\n",
info.processor.modelNumber);
316 fprintf(stdout,
"Processor family : %d\n",
info.processor.family);
317 fprintf(stdout,
"Processor vendor : %s\n",
info.processor.vendor.c_str());
318 fprintf(stdout,
"Processor arch : %s\n",
info.processor.architecture.c_str());
319 fprintf(stdout,
"Processor cores : %d\n",
info.processor.cores);
320 fprintf(stdout,
"Processor siblings : %d\n",
info.processor.siblings);
321 fprintf(stdout,
"Processor Mhz : %.2lf\n\n",
info.processor.frequency);
323 fprintf(stdout,
"Environment variables :\n%s\n",
info.platform.environmentVars.toString().c_str());
332 if (config.
check(
"which"))
336 Help(
"SYNTAX ERROR: missing remote server\n");
347 if (config.
check(
"exit"))
351 Help(
"SYNTAX ERROR: missing remote server\n");
364void yarp::run::Run::Help(
const char *msg)
366 fprintf(stderr,
"%s", msg);
367 fprintf(stderr,
"\nUSAGE:\n\n");
368 fprintf(stderr,
"yarp run --server SERVERPORT\nrun a server on the local machine\n\n");
369 fprintf(stderr,
"yarp run --on SERVERPORT --as TAG --cmd COMMAND [ARGLIST] [--workdir WORKDIR] [--env ENVIRONMENT]\nrun a command on SERVERPORT server\n\n");
370 fprintf(stderr,
"yarp run --on SERVERPORT --as TAG --stdio STDIOSERVERPORT [--hold] [--geometry WxH+X+Y] --cmd COMMAND [ARGLIST] [--workdir WORKDIR] [--env ENVIRONMENT]\n");
371 fprintf(stderr,
"run a command on SERVERPORT server sending I/O to STDIOSERVERPORT server\n\n");
372 fprintf(stderr,
"yarp run --on SERVERPORT --kill TAG SIGNUM\nsend SIGNUM signal to TAG command\n\n");
373 fprintf(stderr,
"yarp run --on SERVERPORT --sigterm TAG\nterminate TAG command\n\n");
374 fprintf(stderr,
"yarp run --on SERVERPORT --sigtermall\nterminate all commands\n\n");
375 fprintf(stderr,
"yarp run --on SERVERPORT --ps\nreport commands running on SERVERPORT\n\n");
376 fprintf(stderr,
"yarp run --on SERVERPORT --isrunning TAG\nTAG command is running?\n\n");
377 fprintf(stderr,
"yarp run --on SERVERPORT --sysinfo\nreport system information of SERVERPORT\n\n");
378 fprintf(stderr,
"yarp run --on SERVERPORT --exit\nstop SERVERPORT server\n\n");
379 fprintf(stderr,
"yarp run --on SERVERPORT --which\nsearch for path of provided filename\n\n");
400 printf(
":: %s\n", msg.
toString().c_str());
402 response=sendMsg(msg, node);
404 if (!response.
size()) {
425 printf(
":: %s\n", msg.
toString().c_str());
428 if (!port.
open(
"..."))
430 fprintf(stderr,
"RESPONSE:\n=========\n");
431 fprintf(stderr,
"Cannot open port, aborting...\n");
437 fprintf(stderr,
"RESPONSE:\n=========\n");
438 fprintf(stderr,
"Cannot connect to remote server, aborting...\n");
443 RUNLOG(
"<<<port.write(msg, info)")
445 RUNLOG(
">>>port.write(msg, info)")
449 fprintf(stdout,
"RESPONSE:\n=========\n\n");
452 fprintf(stdout,
"No response. (timeout)\n");
468 std::string dest_srv=node;
470 if (command.
check(
"stdio"))
479 if (command.
check(
"geometry"))
487 if (command.
check(
"hold"))
506 printf(
":: %s\n", msg.
toString().c_str());
508 response=sendMsg(msg, dest_srv);
511 snprintf(buff,
sizeof(buff),
"%d", response.
get(0).
asInt32());
512 keyv=std::string(buff);
514 return response.
get(0).
asInt32()>0?
true:
false;
531 printf(
":: %s\n", msg.
toString().c_str());
533 response=sendMsg(msg, node);
535 return response.
get(0).
asString()==
"sigterm OK"?
true:
false;
551 printf(
":: %s\n", msg.
toString().c_str());
553 response=sendMsg(msg, node);
555 return response.
get(0).
asString()==
"sigtermall OK"?
true:
false;
573 printf(
":: %s\n", msg.
toString().c_str());
575 response=sendMsg(msg, node);
577 return response.
get(0).
asString()==
"kill OK"?
true:
false;
592 printf(
":: %s\n", msg.
toString().c_str());
594 response=sendMsg(msg, node);
595 for (
size_t i=0; i<response.
size(); i++)
606 processes.push_back(temp);
625 printf(
":: %s\n", msg.
toString().c_str());
627 response=sendMsg(msg, node);
629 if (!response.
size()) {
649 printf(
":: %s\n", msg.
toString().c_str());
651 response=sendMsg(msg, node);
653 if (!response.
size()) {
A simple collection of objects that can be described and transmitted in a portable way.
Bottle & addList()
Places an empty nested list in the bottle, at the end of the list.
size_type size() const
Gets the number of elements in the bottle.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
void clear()
Empties the bottle of any objects it contains.
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
void addString(const char *str)
Places a string in the bottle, at the end of the list.
std::string toString() const override
Gives a human-readable textual representation of the bottle.
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
static bool disconnect(const std::string &src, const std::string &dest, bool quiet)
Request that an output port disconnect from an input port.
A class for storing options and configuration information.
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
std::string toString() const override
Return a standard text representation of the content of the object.
bool check(const std::string &key) const override
Check if there exists a property of the given name.
Bottle & findGroup(const std::string &key) const override
Gets a list corresponding to a given keyword.
A port that is specialized as an RPC client.
A helper class to pass the SystemInfo object around the YARP network.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual Bottle * asList() const
Get list value.
std::string toString() const override
Return a standard text representation of the content of the object.
virtual std::string asString() const
Get string value.
static bool ps(const std::string &node, std::vector< processInfo > &processes)
Get a report of all applications running on a yarprun server.
static bool start(const std::string &node, yarp::os::Property &command, std::string &keyv)
Launch a yarprun server.
static bool sigtermall(const std::string &node)
Terminate all applications running on a yarprun server.
static bool which(const std::string &node, const std::string &keyv)
Display the path of a file on a yarprun server.
static int client(yarp::os::Property &config)
Send a property object to a run server, bundling up all the settings usually specified on the command...
static bool kill(const std::string &node, const std::string &keyv, int s)
Send a SIGNAL to an application running on a yarprun server (Linux only).
static bool isRunning(const std::string &node, const std::string &keyv)
Report if an application is still running on a yarprun server.
static bool sigterm(const std::string &node, const std::string &keyv)
Terminate an application running on a yarprun server.
static bool exit(const std::string &node)
Exit a yarprun server.
static bool sysinfo(const std::string &node, yarp::os::SystemInfoSerializer &info)
Get a report of system information of a yarprun server.