Index: trunk/Ohana/src/opihi/pantasks/CheckSystem.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/CheckSystem.c	(revision 4552)
+++ trunk/Ohana/src/opihi/pantasks/CheckSystem.c	(revision 4573)
@@ -5,4 +5,5 @@
   CheckTasks ();
   CheckJobs ();
+  CheckControllerOutput ();
 
 }
Index: trunk/Ohana/src/opihi/pantasks/ControllerOps.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/ControllerOps.c	(revision 4552)
+++ trunk/Ohana/src/opihi/pantasks/ControllerOps.c	(revision 4573)
@@ -5,4 +5,6 @@
 static int status = FALSE;
 static int stdin_cntl, stdout_cntl, stderr_cntl;
+static IOBuffer stdout_buffer;
+static IOBuffer stderr_buffer;
 
 int CheckControllerStatus () {
@@ -108,5 +110,5 @@
   line = NULL;
   status = -1;
-  for (i = 0; (i < CONTROLLER_TIMEOUT) && (status == -1) && (line == NULL); i++) {
+  for (i = 0; (i < CONTROLLER_TIMEOUT) && (status != 0) && (line == NULL); i++) {
     status = ReadtoIOBuffer (buffer, stdout_cntl);
     if ((buffer[0].Nbuffer - Nstart) >= Nbytes) {
@@ -261,5 +263,5 @@
   p = NULL;
   status = -1;
-  for (i = 0; (i < CONNECT_TIMEOUT) && (status == -1) && (p == NULL); i++) {
+  for (i = 0; (i < CONNECT_TIMEOUT) && (status != 0) && (p == NULL); i++) {
     status = ReadtoIOBuffer (&buffer, stdout_fd[0]);
     p = memstr (buffer.buffer, "CONNECTED", buffer.Nbuffer);
@@ -274,4 +276,7 @@
   stdout_cntl = stdout_fd[0];
   stderr_cntl = stderr_fd[0];
+
+  InitIOBuffer (&stdout_buffer, 0x100);
+  InitIOBuffer (&stderr_buffer, 0x100);
 
   fprintf (stderr, "Connected\n");
@@ -319,5 +324,5 @@
   line = NULL;
   status = -1;
-  for (i = 0; (i < CONTROLLER_TIMEOUT) && (status == -1) && (line == NULL); i++) {
+  for (i = 0; (i < CONTROLLER_TIMEOUT) && (status != 0) && (line == NULL); i++) {
     status = ReadtoIOBuffer (buffer, stdout_cntl);
     line = memstr (buffer[0].buffer, response, buffer[0].Nbuffer);
@@ -330,3 +335,50 @@
 }
 
+int CheckControllerOutput () {
+
+  int Nread;
+
+  /* read stdout buffer */
+  Nread = ReadtoIOBuffer (&stdout_buffer, stdout_cntl);
+  switch (Nread) {
+    case -2:  /* error in read (programming error?  system level error?) */
+      fprintf (stderr, "serious IO error\n");
+      exit (2);
+    case -1:  /* no data in pipe */
+      break;
+    case 0:   /* pipe is closed */
+      /** change child state? **/
+      break;
+    default:  /* data in pipe */
+      break;
+  }
+  
+  /* read stderr buffer */
+  Nread = ReadtoIOBuffer (&stderr_buffer, stderr_cntl);
+  switch (Nread) {
+    case -2:  /* error in read (programming error?  system level error?) */
+      fprintf (stderr, "serious IO error\n");
+      exit (2);
+    case -1:  /* no data in pipe */
+      break;
+    case 0:   /* pipe is closed */
+      /** change child state? **/
+      break;
+    default:  /* data in pipe */
+      break;
+  }
+  return (TRUE);
+}
+
+int PrintControllerOutput () {
+
+  fprintf (stderr, "--- stdout ---\n");
+  fwrite (stdout_buffer.buffer, 1, stdout_buffer.Nbuffer, stderr);
+  fprintf (stderr, "--- stdout ---\n");
+  fwrite (stderr_buffer.buffer, 1, stderr_buffer.Nbuffer, stderr);
+  fprintf (stderr, "---  done  ---\n");
+  return (TRUE);
+}
+
+
 /* memstr returns a view, not an allocated string : don't free */
Index: trunk/Ohana/src/opihi/pantasks/Makefile
===================================================================
--- trunk/Ohana/src/opihi/pantasks/Makefile	(revision 4552)
+++ trunk/Ohana/src/opihi/pantasks/Makefile	(revision 4573)
@@ -48,4 +48,5 @@
 $(SDIR)/controller_check.$(ARCH).o \
 $(SDIR)/controller_status.$(ARCH).o \
+$(SDIR)/controller_output.$(ARCH).o \
 $(SDIR)/task.$(ARCH).o \
 $(SDIR)/task_command.$(ARCH).o \
Index: trunk/Ohana/src/opihi/pantasks/controller.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/controller.c	(revision 4552)
+++ trunk/Ohana/src/opihi/pantasks/controller.c	(revision 4573)
@@ -4,9 +4,11 @@
 int controller_status  PROTO((int, char **));
 int controller_check   PROTO((int, char **));
+int controller_output  PROTO((int, char **));
 
 static Command controller_cmds[] = {
   {"host",   controller_host,   "define host for controller"},
+  {"check",  controller_check,  "check controller host/job"},
   {"status", controller_status, "check controller status"},
-  {"check",  controller_check,  "check controller host/job"},
+  {"output", controller_output, "print controller output"},
 };
 
Index: trunk/Ohana/src/opihi/pantasks/controller_check.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/controller_check.c	(revision 4552)
+++ trunk/Ohana/src/opihi/pantasks/controller_check.c	(revision 4573)
@@ -8,6 +8,6 @@
 
   if (argc != 3) goto usage;
-  if (strcasecmp (argv[2], "JOB") && 
-      strcasecmp (argv[2], "HOST")) goto usage;
+  if (strcasecmp (argv[1], "JOB") && 
+      strcasecmp (argv[1], "HOST")) goto usage;
 
   /* check if controller is running */
@@ -18,5 +18,5 @@
   }
 
-  sprintf (command, "check %s %s", argv[2], argv[3]);
+  sprintf (command, "check %s %s", argv[1], argv[2]);
   InitIOBuffer (&buffer, 0x100);
   status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);
Index: trunk/Ohana/src/opihi/pantasks/controller_host.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/controller_host.c	(revision 4552)
+++ trunk/Ohana/src/opihi/pantasks/controller_host.c	(revision 4573)
@@ -7,5 +7,5 @@
   IOBuffer buffer;
 
-  if (argc != 3) {
+  if (argc != 2) {
     fprintf (stderr, "USAGE: controller host (hostname)\n");
     return (FALSE);
@@ -15,5 +15,5 @@
   StartController ();
 
-  sprintf (command, "host %s", argv[2]);
+  sprintf (command, "host %s", argv[1]);
   InitIOBuffer (&buffer, 0x100);
   status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);
@@ -32,4 +32,6 @@
     case CONTROLLER_GOOD:
       fprintf (stderr, "controller command sent\n");  
+      fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr);
+      fprintf (stderr, "\n Nbytes received: %d\n", buffer.Nbuffer);  
       return (TRUE);
 
Index: trunk/Ohana/src/opihi/pantasks/controller_output.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/controller_output.c	(revision 4573)
+++ trunk/Ohana/src/opihi/pantasks/controller_output.c	(revision 4573)
@@ -0,0 +1,16 @@
+# include "scheduler.h"
+
+int controller_output (int argc, char **argv) {
+
+  int status;
+  char command[1024];
+  IOBuffer buffer;
+
+  if (argc != 1) {
+    fprintf (stderr, "USAGE: controller status\n");
+    return (FALSE);
+  }
+
+  PrintControllerOutput ();
+  return (TRUE);
+}
Index: trunk/Ohana/src/opihi/pantasks/controller_status.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/controller_status.c	(revision 4552)
+++ trunk/Ohana/src/opihi/pantasks/controller_status.c	(revision 4573)
@@ -7,5 +7,5 @@
   IOBuffer buffer;
 
-  if (argc != 3) {
+  if (argc != 1) {
     fprintf (stderr, "USAGE: controller status\n");
     return (FALSE);
@@ -37,4 +37,5 @@
       fprintf (stderr, "controller command sent\n");  
       fwrite (buffer.buffer, 1, buffer.Nbuffer, stderr);
+      fprintf (stderr, "\n Nbytes received: %d\n", buffer.Nbuffer);  
       return (TRUE);
 
