summaryrefslogtreecommitdiff
path: root/services/unix_exec_service
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss@sss.chaoslab.ru>2013-02-12 21:34:09 +0200
committerGluzskiy Alexandr <sss@sss.chaoslab.ru>2013-02-12 21:34:09 +0200
commit85a13d70cc5249e2f583bb16f0914646aefe4fe6 (patch)
tree3c83832a146120a8ec8f026ab97af2698936e72c /services/unix_exec_service
parent1d41574c6e8e7bbf3705645feb429df6281ccb83 (diff)
server and shell exec module should work now
TODO: implement basic protocol support in client
Diffstat (limited to 'services/unix_exec_service')
-rw-r--r--services/unix_exec_service/main.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/services/unix_exec_service/main.cpp b/services/unix_exec_service/main.cpp
index ad7da1f..331c98f 100644
--- a/services/unix_exec_service/main.cpp
+++ b/services/unix_exec_service/main.cpp
@@ -58,8 +58,21 @@ void * shell_exec(void * t)
cmd = c;
if(!cmd.empty())
{
+ FILE *f = popen(cmd.c_str(), "r");
+ if(f)
+ {
+ std::string *ret = new std::string;
+ char buf[128];
+ while(fgets(buf, 128, f))
+ ret->append(buf);
+ return (void*)ret;
+ }
+ else
+ {
+ //TODO: handle fail (need to extend service api ?)
+ }
}
- return NULL;
+ return (void*)new std::string;
}
void load_cmds()
@@ -99,15 +112,17 @@ void load_cmds()
p1++;
descr = str.substr(p1);
}
+ service_info::command c;
if(!_alias.empty())
{
alias a;
a._alias = _alias;
a.cmd = cmd;
+ c.command = _alias;
aliases.push_back(a);
}
- service_info::command c;
- c.command = cmd;
+ else
+ c.command = cmd;
c.description = descr;
cmds.push_back(c);
// printf("%s | %s | %s\n", _alias.c_str(), cmd.c_str(), descr.c_str());
@@ -123,7 +138,7 @@ services(get_services)
{
service_info shell_exec_service;
shell_exec_service.acc = ACC_CHAR_PTR;
- shell_exec_service.ret = RET_STD_STRING;
+ shell_exec_service.ret = RET_STD_STRING_PTR;
shell_exec_service.name = "Shell exec";
shell_exec_service.description = "Run shell command and return output";
shell_exec_service.exec = &shell_exec;