Sending an email with logfile when a FlowTracer job fails

Call this script in POSTCMD, by adding a property P POSTCMD <name of script>

The following will result (or something very similar).
#!/bin/csh
# -*- Tcl -*- \
    exec vovsh -f $0 $*:q

set VOV_JOBID [lindex $argv 0]

vtk_transition_get $VOV_JOBID jobInfo
# generate status message in .postcmd.log ?
# puts "status is $jobInfo(status)"

if { $jobInfo(status) == "FAILED" } {
    set jobcmd $jobInfo(cmd)
    set outputs [lindex [vtk_node_get_ios $VOV_JOBID "@id@ @islog@ @name@ " ] 1]

    foreach el $outputs {
        # find the logfiles among all the outputs
        set islog [lindex $el 1]
        if { $islog == 0 } { continue }

        set ftname [lindex $el 2]
        set fullname [vtk_path_expand $ftname]

        # may need to wait until the file is available through NFS
#       after 1000
        eval { exec sh -c " /usr/bin/tail $fullname | mail <userid>@domain.com -s \"job $VOV_JOBID failed\" "  }
    }
}

Did you find this article helpful?