Command executed: ". $cmd ."

"; $exp_cmd = "export DSH_CONTEXT=XCAT XCATROOT=/opt/xcat; "; if ($copy == "on"){ //using dcp/prcp //extract the script name from the command $script = strtok($cmd,' '); //copy the command to the remote node $source = "/opt/xcat/bin/" . $script; //copy from $target = "/tmp"; //copy to if ($psh == "off"){ $copy_cmd = $exp_cmd . "sudo " . $copy_cmd . $node_group . " " . $source . " " . $target; }else{ $copy_cmd = "sudo " . $copy_cmd . $source . " " . $node_group . ":" . $target; } runcmd($copy_cmd,1, $outp); if ($psh != "on"){ $command_string = $exp_cmd . "sudo ". $command. $node_group . " /tmp/" . $cmd; }else{ $command_string = "sudo " . $command . $node_group . " /tmp/" . $cmd; } } else{ if ($psh != "on"){ $command_string = $exp_cmd . "sudo ". $command. $node_group . " " . $cmd; }else{ $command_string = "sudo " . $command . $node_group . " " . $cmd; } } //using dshbak to format the output $command_string .= " | $SYSTEMROOT/dshbak "; if ($collapse == "on") $command_string .= "-c "; echo " Full command (for TEST purpose): " . $command_string . "
"; echo "

Command Ouput:

"; //output will be returned from the runcmd function call //run the script if ($ret_code == "on"){ $rc = runcmd($command_string,0, $outp); //mode 0 if ($rc == 0){ foreach ($outp as $key => $val){ echo $val. "
"; } } }else{ //$rc = runcmd($command_string,1, $outp); //streaming mode COMMENTED AS BY SOME WAY THIS DOESN'T WORK YET $rc = runcmd($command_string,0, $outp); //mode 0 if ($rc == 0){ foreach ($outp as $key => $val){ echo $val. "
"; } } } /*************************************************************************************** * TEST PART * for now just use system command on the server, not using psh to run cmds on the nodes ***************************************************************************************/ //test case 1: mode 1 (or -1) /*$rc = runcmd($cmd,1, $outp); echo "
RC to caller: " . $rc . "
";*/ //passed //test case 2: mode 3 /*$rc = runcmd($cmd,3, $outp, array('NoRedirectStdErr' => TRUE)); echo "RC to caller: " . $rc . "
"; echo "Ouput file handle: " . $outp . "
"; echo "Results: " . "
"; if ($outp){ while (!feof($outp)){ $read = fgets($outp); echo $read; } }*/ //passed //testcase 3: mode 0 /*$rc = runcmd($cmd,0, $outp, array('NoRedirectStdErr' => TRUE)); if ($rc == 0) echo "Results: "; foreach ($outp as $key => $val){ echo $val. ";"; }*/ //passed //testcase 4: mode 2 /*$rc = runcmd($cmd,2, $outp, array('NoRedirectStdErr' => TRUE)); echo "Results: " . $outp;*/ //passed /* //history cookie if ($rc == 0){ // no error if (isset($_COOKIE["history"])){ //append to the old cookie //avoid repetitive entries when user hit "Refresh" button if (strstr($_COOKIE["history"], ';') == FALSE){ //just have one entry in the history cookie if (strcmp($_COOKIE["history"],$cmd_text) <> 0){ $cmd_history = $_COOKIE["history"] . ";" . $cmd_text; setcookie("history",$cmd_history,$expire_time); } } else { $string = $_COOKIE["history"]; $token = strtok($string, ';'); $is_repetitive = 0; if (strcmp($token,$cmd_text) <> 0) $is_repetitive = 1; while (FALSE !== ($token = strtok(';'))) { if (strcmp($token,$cmd_text) <> 0) $is_repetitive = 1; } if ($is_repetitive == 0){ //the new command is not repetitive $cmd_history = $_COOKIE["history"] . ";" . $cmd_text; setcookie("history",$cmd_history,$expire_time); } } } else{ //first time, write new $cmd_history = $cmd_text; setcookie("history",$cmd_history,$expire_time); //cookie lasts 30 days } }*/ ?>