= How do I use submit with Rappture? = {{{submit}}} can be called from a Rappture wrapper script for remote batch job submission. == Use from a Tcl wrapper == This code segment is used to catch the {{{Abort}}} button interrupt. Setting {{{execctl}}} to 1 will terminate the process and any child processes. {{{ package require Rappture Rappture::signal SIGHUP sHUP { puts "Caught SIGHUP" set execctl 1 } Rappture::signal SIGTERM sTERM { puts "Caught SIGTERM" set execctl 1 } }}} This code segment builds an executable script that can executed using {{{Rappture::exec}}}. The {{{trap}}} statement will catch the interrupt thrown when the wrapper script execution is {{{Abort}}}ed. Putting the {{{submit}}} command in the background allows for the possibility of issuing multiple {{{submit}}} commands from the script. The {{{wait}}} statement forces the shell script to wait for all {{{submit}}} commands to terminate before terminating. {{{ set submitScript "#!/bin/sh\n\n" append submitScript "trap cleanup HUP INT QUIT ABRT TERM\n\n" append submitScript "cleanup()\n" append submitScript "{\n" append submitScript " kill -TERM `jobs -p`\n" append submitScript " exit 1\n" append submitScript "}\n\n" append submitScript "cd [pwd]\n" append submitScript "submit -v violin -n $nodes -w $walltime\\\n" append submitScript " COMMAND ARGUMENTS &\n" append submitScript "sleep 5\n" append submitScript "wait\n" set submitScriptPath [file join [pwd] submit_script.sh] set fid [open $submitScriptPath w] puts $fid $submitScript close $fid file attributes $submitScriptPath -permissions 00755 }}} Next use the standard method for execution. This will stream the output from all {{{submit}}} commands contained in {{{submit_script.sh}}} to the GUI display. The same output will be retained in the variable {{{out}}}. {{{ set status [catch {Rappture::exec $submitScriptPath} out] }}} Each {{{submit}}} command creates a files to hold COMMAND standard output and standard error. The file names are of the form JOBID.stdout and JOBID.stderr, where JOBID is an 8 digit number. These results can be gathered as follows. {{{ set out2 "" foreach errfile [glob -nocomplain *.stderr] { if [file size $errfile] { if {[catch {open $errfile r} fid] == 0} { set info [read $fid] close $fid append out2 $info } } file delete -force $errfile } foreach outfile [glob -nocomplain *.stdout] { if [file size $outfile] { if {[catch {open $outfile r} fid] == 0} { set info [read $fid] close $fid append out2 $info } } file delete -force $outfile } }}} The script file should be removed. {{{ file delete -force $submitScriptPath }}} The output is presented as the job output log. {{{ $driver put output.log $out2 }}} All other result processing can proceed as normal.