     dst->set_target(src->target);
  
     return dst;   
-@@ -95,9 +106,12 @@
+@@ -95,9 +104,12 @@
  void free_runscript(RUNSCRIPT *script)
  {
     Dmsg0(500, "runscript: freeing RUNSCRIPT object\n");

-   
    target = NULL;
-   command = NULL;
+   if (commands) {
+      delete commands;
+      commands = NULL;
+   }
    on_success = true;
    on_failure = false;
    fail_on_error = true;
@@ -76,17 +81,23 @@
    job_code_callback = NULL;
 }
 
-RUNSCRIPT *copy_runscript(RUNSCRIPT *src)
+Runscript *copy_runscript(RUNSCRIPT *src)
 {
    Dmsg0(500, "runscript: creating new RUNSCRIPT object from other\n");
 
    RUNSCRIPT *dst = (RUNSCRIPT *)malloc(sizeof(RUNSCRIPT));
    memcpy(dst, src, sizeof(RUNSCRIPT));
 

+   commands->append(c);
 }
 
+/* command = ( SHELL_CMD | CONSOLE_CMD ) command */
+void RUNSCRIPT::get_command(const char* command, int *acmd_type, char **cmd)
+{
+   *acmd_type = (int) command[0];
+   *cmd = (char *)command + 1;
+}
+
 /* set this->target to client_name */
 void RUNSCRIPT::set_target(const POOLMEM *client_name)
 {
@@ -210,14 +185,70 @@
 
 bool RUNSCRIPT::run(JCR *jcr, const char *name)
 {
