Index: /trunk/Ohana/src/opihi/pantasks/controller.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/controller.c	(revision 4538)
+++ /trunk/Ohana/src/opihi/pantasks/controller.c	(revision 4539)
@@ -1,48 +1,41 @@
 # include "scheduler.h"
+
+static Command controller_cmds[] = {
+  {"host",   controller_host,   "define host for controller"},
+  {"status", controller_status, "check controller status"},
+  {"check",  controller_check,  "check controller host/job"},
+};
 
 int controller (int argc, char **argv) {
 
   int status;
-  char command[1024];
-  IOBuffer buffer;
+  Function *func;
 
-  if (argc != 3) {
-    fprintf (stderr, "USAGE: controller host (hostname)\n");
+  if (argc < 2) {
+    fprintf (stderr, "USAGE: controller (command) ... \n");
     return (FALSE);
   }
 
-  if (strcmp (argv[1], "host")) {
+  func = FindControllerCommand (argv[1]);
+  if (func == NULL) {
     fprintf (stderr, "invalid controller command\n");
     return (FALSE);
   }
 
-  /* start controller connection (if needed) */
-  StartController ();
+  status = (*func)(argc - 1, argv + 1);
+  return (status);
+}
 
-  sprintf (command, "host %s", argv[2]);
-  InitIOBuffer (&buffer, 0x100);
-  status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);
-  FreeIOBuffer (&buffer);
+Function *FindControllerCommand (char *cmd) {
 
-  /* check on success of controller command */
-  switch (status) {
-    case CONTROLLER_DOWN:
-      fprintf (stderr, "controller is down\n");
-      return (FALSE);
+  int i, N;
 
-    case CONTROLLER_HUNG:
-      fprintf (stderr, "controller is not responding\n");
-      return (FALSE);
+  N = sizeof (controller_cmds) / sizeof (Command);
 
-    case CONTROLLER_GOOD:
-      fprintf (stderr, "controller command sent\n");  
-      return (TRUE);
-
-    default:
-      fprintf (stderr, "unknown status for controller command: programming error\n");  
-      exit (1);
+  for (i = 0; i < N; i++) {
+    if (!strcmp (controller_cmds[i].name, argv[1])) {
+      return (controller_cmds[i].func);
+    }
   }
-
-  fprintf (stderr, "programming error: should not reach here\n");  
-  exit (1);
+  return (NULL);
 }
Index: /trunk/Ohana/src/opihi/pantasks/controller_check.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/controller_check.c	(revision 4539)
+++ /trunk/Ohana/src/opihi/pantasks/controller_check.c	(revision 4539)
@@ -0,0 +1,43 @@
+# include "scheduler.h"
+
+int controller_host (int argc, char **argv) {
+
+  int status;
+  char command[1024];
+  IOBuffer buffer;
+
+  if (argc != 3) {
+    fprintf (stderr, "USAGE: controller host (hostname)\n");
+    return (FALSE);
+  }
+
+  /* start controller connection (if needed) */
+  StartController ();
+
+  sprintf (command, "host %s", argv[2]);
+  InitIOBuffer (&buffer, 0x100);
+  status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);
+  FreeIOBuffer (&buffer);
+
+  /* check on success of controller command */
+  switch (status) {
+    case CONTROLLER_DOWN:
+      fprintf (stderr, "controller is down\n");
+      return (FALSE);
+
+    case CONTROLLER_HUNG:
+      fprintf (stderr, "controller is not responding\n");
+      return (FALSE);
+
+    case CONTROLLER_GOOD:
+      fprintf (stderr, "controller command sent\n");  
+      return (TRUE);
+
+    default:
+      fprintf (stderr, "unknown status for controller command: programming error\n");  
+      exit (1);
+  }
+
+  fprintf (stderr, "programming error: should not reach here\n");  
+  exit (1);
+}
Index: /trunk/Ohana/src/opihi/pantasks/controller_host.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/controller_host.c	(revision 4539)
+++ /trunk/Ohana/src/opihi/pantasks/controller_host.c	(revision 4539)
@@ -0,0 +1,43 @@
+# include "scheduler.h"
+
+int controller_host (int argc, char **argv) {
+
+  int status;
+  char command[1024];
+  IOBuffer buffer;
+
+  if (argc != 3) {
+    fprintf (stderr, "USAGE: controller host (hostname)\n");
+    return (FALSE);
+  }
+
+  /* start controller connection (if needed) */
+  StartController ();
+
+  sprintf (command, "host %s", argv[2]);
+  InitIOBuffer (&buffer, 0x100);
+  status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);
+  FreeIOBuffer (&buffer);
+
+  /* check on success of controller command */
+  switch (status) {
+    case CONTROLLER_DOWN:
+      fprintf (stderr, "controller is down\n");
+      return (FALSE);
+
+    case CONTROLLER_HUNG:
+      fprintf (stderr, "controller is not responding\n");
+      return (FALSE);
+
+    case CONTROLLER_GOOD:
+      fprintf (stderr, "controller command sent\n");  
+      return (TRUE);
+
+    default:
+      fprintf (stderr, "unknown status for controller command: programming error\n");  
+      exit (1);
+  }
+
+  fprintf (stderr, "programming error: should not reach here\n");  
+  exit (1);
+}
Index: /trunk/Ohana/src/opihi/pantasks/controller_status.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/controller_status.c	(revision 4539)
+++ /trunk/Ohana/src/opihi/pantasks/controller_status.c	(revision 4539)
@@ -0,0 +1,43 @@
+# include "scheduler.h"
+
+int controller_host (int argc, char **argv) {
+
+  int status;
+  char command[1024];
+  IOBuffer buffer;
+
+  if (argc != 3) {
+    fprintf (stderr, "USAGE: controller host (hostname)\n");
+    return (FALSE);
+  }
+
+  /* start controller connection (if needed) */
+  StartController ();
+
+  sprintf (command, "host %s", argv[2]);
+  InitIOBuffer (&buffer, 0x100);
+  status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);
+  FreeIOBuffer (&buffer);
+
+  /* check on success of controller command */
+  switch (status) {
+    case CONTROLLER_DOWN:
+      fprintf (stderr, "controller is down\n");
+      return (FALSE);
+
+    case CONTROLLER_HUNG:
+      fprintf (stderr, "controller is not responding\n");
+      return (FALSE);
+
+    case CONTROLLER_GOOD:
+      fprintf (stderr, "controller command sent\n");  
+      return (TRUE);
+
+    default:
+      fprintf (stderr, "unknown status for controller command: programming error\n");  
+      exit (1);
+  }
+
+  fprintf (stderr, "programming error: should not reach here\n");  
+  exit (1);
+}
Index: /trunk/Ohana/src/opihi/pantasks/delete.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/delete.c	(revision 4539)
+++ /trunk/Ohana/src/opihi/pantasks/delete.c	(revision 4539)
@@ -0,0 +1,42 @@
+# include "pcontrol.h"
+
+int delete (int argc, char **argv) {
+
+  Job *job;
+  int JobID, N;
+
+  if (argc < 2) {
+    fprintf (stderr, "USAGE: delete (JobID)\n");
+    return (FALSE);
+  }
+  JobID = atoi (argv[1]);
+  /* use a string interp to convert JobIDs to ints ? */
+
+  job = PullJob (JobID, PCONTROL_JOB_PENDING);
+  if (job != NULL) goto found;
+
+  job = PullJob (JobID, PCONTROL_JOB_CRASH);
+  if (job != NULL) goto found;
+
+  job = PullJob (JobID, PCONTROL_JOB_EXIT);
+  if (job != NULL) goto found;
+
+  fprintf (stderr, "job %s not PENDING, CRASH, EXIT\n", argv[1]);
+  return (FALSE);
+  
+found:
+  {
+    int j;
+    fprintf (stderr, "deleting job  %s  %d  ", job[0].hostname, job[0].argc);
+    for (j = 0; j < job[0].argc; j++) {
+      fprintf (stderr, "%s ", job[0].argv[j]);
+    }
+    PrintID (stderr, job[0].JobID);
+    fprintf (stderr, "\n");
+  }  
+  DelJob (job);
+
+  return (TRUE);
+}
+
+/* find job from jobID, kill and delete */
Index: /trunk/Ohana/src/opihi/pantasks/init.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/init.c	(revision 4538)
+++ /trunk/Ohana/src/opihi/pantasks/init.c	(revision 4539)
@@ -21,4 +21,13 @@
   {"run",        run,          "run the scheduler"},
   {"stop",       stop,         "stop the scheduler"},
+
+  {"kill",       kill_sh,      "kill job"},
+  {"delete",     delete,       "delete job"},
+  {"job",        job,          "add job"},
+  {"host",       host,         "add / delete / modify host"},
+  {"check",      check,        "get job or host status"},
+  {"status",     status,       "get system status"},
+  {"stdout",     stdout_pc,    "get stdout buffer for job"},
+  {"stderr",     stderr_pc,    "get stderr buffer for job"},
 }; 
 
Index: /trunk/Ohana/src/opihi/pantasks/job.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/job.c	(revision 4539)
+++ /trunk/Ohana/src/opihi/pantasks/job.c	(revision 4539)
@@ -0,0 +1,52 @@
+# include "pcontrol.h"
+
+int job (int argc, char **argv) {
+
+  char *Host, **targv;
+  int i, N, Mode, targc, Timeout;
+  IDtype JobID;
+
+  Host = NULL;
+  Mode = PCONTROL_JOB_ANYHOST;
+  if ((N = get_argument (argc, argv, "-host"))) {
+    remove_argument (N, &argc, argv);
+    Host = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+    Mode = PCONTROL_JOB_WANTHOST;
+  }
+  if ((N = get_argument (argc, argv, "+host"))) {
+    if (Mode == PCONTROL_JOB_WANTHOST) {
+      fprintf (stderr, "ERROR: -host and +host are incompatible\n");
+      FREE (Host);
+      return (FALSE);
+    }
+    remove_argument (N, &argc, argv);
+    Host = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+    Mode = PCONTROL_JOB_NEEDHOST;
+  }
+  if (Host == NULL) Host = strcreate ("anyhost");
+ 
+  Timeout = 100;
+  if ((N = get_argument (argc, argv, "-timeout"))) {
+    remove_argument (N, &argc, argv);
+    Timeout = atoi (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  if (argc < 2) {
+    fprintf (stderr, "USAGE: job [options] (arg0) (arg1) ... (argN)\n");
+    FREE (Host);
+    return (FALSE);
+  }
+  
+  targc = argc - 1;
+  ALLOCATE (targv, char *, targc);
+  for (i = 1; i < argc; i++) {
+    targv[i-1] = strcreate (argv[i]);
+  }
+
+  JobID = AddJob (Host, Mode, Timeout, targc, targv);
+  fprintf (stdout, "JobID: %d\n", JobID);
+  return (TRUE);
+}
Index: /trunk/Ohana/src/opihi/pantasks/kill.c
===================================================================
--- /trunk/Ohana/src/opihi/pantasks/kill.c	(revision 4539)
+++ /trunk/Ohana/src/opihi/pantasks/kill.c	(revision 4539)
@@ -0,0 +1,23 @@
+# include "pcontrol.h"
+
+int kill_pc (int argc, char **argv) {
+
+  Job *job;
+  int JobID, N;
+
+  if (argc < 2) {
+    fprintf (stderr, "USAGE: kill (JobID)\n");
+    return (FALSE);
+  }
+  JobID = atoi (argv[1]);
+
+  job = PullJob (JobID, PCONTROL_JOB_BUSY);
+  if (job == NULL) {
+    fprintf (stderr, "job %s not BUSY\n", argv[1]);
+    return (FALSE);
+  }
+  KillJob (job);
+  return (TRUE);
+}
+
+/* find job from jobID, kill locally or on controller */
