From cc820a1c3c26041b68bf86874e7be2db01b1991e Mon Sep 17 00:00:00 2001 From: bloodstalker Date: Sat, 4 Mar 2017 13:18:48 +0330 Subject: now runs a command and returns the output, missing stderr --- daemon/mutatorserver.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'daemon') diff --git a/daemon/mutatorserver.c b/daemon/mutatorserver.c index 04e2cd2..c3224d7 100644 --- a/daemon/mutatorserver.c +++ b/daemon/mutatorserver.c @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.* #include "mutatorserver.h" /*standard headers*/ #include +#include #include #include #include @@ -78,8 +79,30 @@ int main (int argc, char *argv[]) /*recieve a message from client*/ while((read_size = recv(client_sock, client_message, 2000, 0)) > 0) { - /*send the message back to the client*/ - write(client_sock, client_message, strlen(client_message)); + FILE* clientistream; + char runresponse[2000]; +#if 0 + /*get the mutator driver command*/ + if (system(client_message) < 0) + { + puts("server returned an error."); + } +#endif + /*open pipe, run command*/ + if (!(clientistream = popen(client_message, "r"))) + { + + } + puts ("task completed."); + + while (fgets(runresponse, sizeof(runresponse), clientistream) != NULL) + { + write(client_sock, runresponse, strlen(runresponse)); + } + puts("read from temp file."); + + /*close pipe*/ + pclose(clientistream); } if (read_size == 0) -- cgit v1.2.3