Index: trunk/Ohana/src/opihi/pantasks/ControllerOps.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/ControllerOps.c	(revision 4451)
+++ trunk/Ohana/src/opihi/pantasks/ControllerOps.c	(revision 4452)
@@ -5,46 +5,4 @@
 int status = FALSE;
 int stdin_cntl, stdout_cntl, stderr_cntl;
-
-/* we read Nbytes from the host, then watch for the prompt */ 
-int GetJobOutput (char *cmd, int pid, IOBuffer *buffer, int Nbytes) {
-  
-  int i, status, Nstart;
-  char *line;
-
-  /* flush any earlier messages */
-  ReadtoIOBuffer (buffer, stdout_cntl);
-  FlushIOBuffer (buffer);
-  Nstart = buffer[0].Nbuffer;
-
-  /* send command to get appropriate channel */
-  ALLOCATE (line, char, MAX (1, strlen(cmd) + 15));
-  sprintf (line, "%s %d\n", cmd, pid);
-  status = write (stdin_cntl, line, strlen(line));
-  free (line);
-
-  /* is pipe still open? */
-  if ((status == -1) && (errno == EPIPE)) return (CONTROLLER_DOWN);
-
-  /* read at least Nbytes, then watch for CONTROLLER_PROMPT */
-  line = NULL;
-  status = -1;
-  for (i = 0; (i < CONTROLLER_TIMEOUT) && (status == -1) && (line == NULL); i++) {
-    status = ReadtoIOBuffer (buffer, stdout_cntl);
-    if ((buffer[0].Nbuffer - Nstart) >= Nbytes) {
-      line = memstr (buffer[0].buffer, CONTROLLER_PROMPT, buffer[0].Nbuffer);
-    }
-    if (status == -1) usleep (10000);
-  }
-  if (status ==  0) return (CONTROLLER_DOWN);
-  if (status == -1) return (CONTROLLER_HUNG);
-
-  fprintf (stderr, "message received (GetJobOutput : %s)\n", cmd);  
-  /* drop extra bytes from pcontrol (not pclient:job) */
-  buffer[0].Nbuffer = Nstart + Nbytes;
-  if (buffer[0].Nalloc > buffer[0].Nbuffer) {
-    bzero (buffer[0].buffer + buffer[0].Nbuffer, buffer[0].Nalloc - buffer[0].Nbuffer);
-  }
-  return (CONTROLLER_GOOD);
-}
 
 int CheckControllerJob (Job *job) {
@@ -123,4 +81,46 @@
 }
 
+/* we read Nbytes from the host, then watch for the prompt */ 
+int GetJobOutput (char *cmd, int pid, IOBuffer *buffer, int Nbytes) {
+  
+  int i, status, Nstart;
+  char *line;
+
+  /* flush any earlier messages */
+  ReadtoIOBuffer (buffer, stdout_cntl);
+  FlushIOBuffer (buffer);
+  Nstart = buffer[0].Nbuffer;
+
+  /* send command to get appropriate channel */
+  ALLOCATE (line, char, MAX (1, strlen(cmd) + 15));
+  sprintf (line, "%s %d\n", cmd, pid);
+  status = write (stdin_cntl, line, strlen(line));
+  free (line);
+
+  /* is pipe still open? */
+  if ((status == -1) && (errno == EPIPE)) return (CONTROLLER_DOWN);
+
+  /* read at least Nbytes, then watch for CONTROLLER_PROMPT */
+  line = NULL;
+  status = -1;
+  for (i = 0; (i < CONTROLLER_TIMEOUT) && (status == -1) && (line == NULL); i++) {
+    status = ReadtoIOBuffer (buffer, stdout_cntl);
+    if ((buffer[0].Nbuffer - Nstart) >= Nbytes) {
+      line = memstr (buffer[0].buffer, CONTROLLER_PROMPT, buffer[0].Nbuffer);
+    }
+    if (status == -1) usleep (10000);
+  }
+  if (status ==  0) return (CONTROLLER_DOWN);
+  if (status == -1) return (CONTROLLER_HUNG);
+
+  fprintf (stderr, "message received (GetJobOutput : %s)\n", cmd);  
+  /* drop extra bytes from pcontrol (not pclient:job) */
+  buffer[0].Nbuffer = Nstart + Nbytes;
+  if (buffer[0].Nalloc > buffer[0].Nbuffer) {
+    bzero (buffer[0].buffer + buffer[0].Nbuffer, buffer[0].Nalloc - buffer[0].Nbuffer);
+  }
+  return (CONTROLLER_GOOD);
+}
+
 /* submitting a job to the controller automatically starts controller */
 int SubmitControllerJob (Job *job) {
@@ -165,10 +165,13 @@
   }
 
+  fprintf (stderr, "sending command to controller: %s\n", cmd);
   InitIOBuffer (&buffer, 0x100);
   ControllerCommand (cmd, CONTROLLER_PROMPT, &buffer);
   free (cmd);
 
+  fprintf (stderr, "response from controller: %s\n", buffer.buffer);
+
   /* extract the job PID from the controller response */
-  p = memstr (buffer.buffer, "STATUS", buffer.Nbuffer);
+  p = memstr (buffer.buffer, "JobID", buffer.Nbuffer);
   if (p == NULL) {
     fprintf (stderr, "missing PID in pcontrol message : programming error\n");
@@ -298,6 +301,7 @@
   FlushIOBuffer (buffer);
 
+  fprintf (stderr, "send: %s\n", cmd);
+
   /* send command to client (adding on \n) */
-  /* fprintf (stderr, "send: %s (%d)\n", command, buffer[0].Nbuffer); */
   ALLOCATE (line, char, MAX (1, strlen(cmd)));
   sprintf (line, "%s\n", cmd);
