13 char outfile[] =
"/tmp/dim_rsh_server.dat";
15 char outfile[] =
"c:\\dim_rch_server.dat";
29 result =
new char[10];
30 strcpy(result,
"empty");
31 resultSrvc =
new DimService(resultName,
"C", result, strlen(result)+1);
38 char commandString[256];
41 int ret,
size, index, sz;
47 cout <<
"Received " << str <<
" from " << client << endl;
49 strcpy(commandString,str);
51 strcat(commandString,
" >& ");
53 strcat(commandString,
"< /dev/null");
55 strcat(commandString,
" > ");
57 strcat(commandString,
" 2>&1 ");
66 strcpy(
result,
"File does not exist");
71 result =
new char[size +1];
74 while(!feof(fd) && size)
76 sz = fread(&
result[index], 1, 512, fd);
94 int pid, status, ret, n = 0;
107 execve(
"/bin/sh", argv,
environ);
111 ret = waitpid(pid, &status,WNOHANG);
123 return system(command);
131 WORD wVersionRequested;
134 static int sock_init_done = 0;
136 if(sock_init_done)
return(1);
137 wVersionRequested = MAKEWORD( 2, 0 );
138 err = WSAStartup( wVersionRequested, &wsaData );
144 if ( LOBYTE( wsaData.wVersion ) != 2 ||
145 HIBYTE( wsaData.wVersion ) != 0 ) {
155 void main(
int argc,
char **argv)
157 char host[64], cmd_name[128], result_name[128];
163 gethostname(host, 64);
166 sprintf(cmd_name,
"%s/ExecuteCmd",host);
167 sprintf(result_name,
"%s/CmdResult", host);
168 cmd =
new Cmd(cmd_name, result_name);
170 sprintf(cmd_name,
"%s_server",host);
static char * getClientName()
Cmd(char *cmdName, char *resultName)
void main(int argc, char **argv)
sprintf(name1,"NewService%d", i)