FACT++  1.0
void Cmd::commandHandler ( )
privatevirtual

Reimplemented from DimCommand.

Definition at line 35 of file rshServer.cxx.

References environ, DimServer::getClientName(), DimCommand::getString(), my_system(), outfile, result, resultSrvc, size, str, and DimService::updateService().

36 {
37  char *str, *client;
38  char commandString[256];
39  struct stat buf;
40  FILE *fd;
41  int ret, size, index, sz;
42 
43  str = getString();
44 
45  client = DimServer::getClientName();
46 
47  cout << "Received " << str << " from " << client << endl;
48  unlink(outfile);
49  strcpy(commandString,str);
50 #ifndef WIN32
51  strcat(commandString," >& ");
52  strcat(commandString,outfile);
53  strcat(commandString,"< /dev/null");
54 #else
55  strcat(commandString," > ");
56  strcat(commandString,outfile);
57  strcat(commandString," 2>&1 ");
58 #endif
59  my_system(commandString);
60 
61  delete result;
62  ret = stat(outfile, &buf);
63  if(ret == -1)
64  {
65  result = new char[20];
66  strcpy(result,"File does not exist");
67  }
68  else
69  {
70  size = buf.st_size;
71  result = new char[size +1];
72  fd = fopen(outfile, "r");
73  index = 0;
74  while(!feof(fd) && size)
75  {
76  sz = fread(&result[index], 1, 512, fd);
77  size -= sz;
78  index += sz;
79  if(!sz)
80  break;
81  }
82  fclose(fd);
83  result[index] = '\0';
84  }
86 }
char * result
Definition: rshServer.cxx:22
static char * getClientName()
Definition: discpp.cxx:579
DimService * resultSrvc
Definition: rshServer.cxx:23
char str[80]
Definition: test_client.c:7
char * getString()
Definition: discpp.cxx:1438
char outfile[]
Definition: rshServer.cxx:13
int updateService()
Definition: discpp.cxx:1016
int size
Definition: db_dim_server.c:17
int my_system(char *)
Definition: rshServer.cxx:92

+ Here is the call graph for this function: