From: Greg Ercolano <erco@(email surpressed)>
Subject: [Q+A] Rush "donemail" -- how do I send Rush reports in a fixed width
   Date: Mon, 04 May 2015 15:11:11 -0400
Msg# 2393
View Complete Thread (2 articles) | All Threads
Last Next
> We use rush 'donemail' to send the reports to users and management
> about completed jobs.
>
> The reports rush sends are plain text ascii, and look OK if your mail reader
> is set up to show plain-text messages in a monospace font.
>
> But many of the non-tech recipients have mail clients that show these messages
> in a /variable/ width font
, making the columns hard to read due to ragged columns.
>
> Is there a way for the emails to force a fixed width font for these reports?
> Can this feature be added to the "rushsendmail" program?


    Mmm, good point, yes, I can probably add that to rushsendmail,
    or perhaps as a flag in the rush.conf.


    For now you can get what you want if your jobs use 'jobdonecommand'
    (instead of 'donemail') and have that run a script of your own, e.g.

rush -submit << EOF
..
jobdonecommand perl
/yourserver/rushscripts/jobdonescript.pl prod@your.dom
..
EOF

    ..and that script generates the reports as email with html formatting,
    so that you can take control of the font used to display the message.

    As a simple example, let's say you want a script to email the
    'rush -lj', 'rush -lfi' and 'rush -lf' reports "To:" prod@your.dom,
    and have the message be "From:" rush@your.dom..

    And more importantly, have the email sent in an html fixed width format.
    The red text in the script below highlights the bit that does that.

    The below script is one way to do it, using rushsendmail to deliver
    the message. (Another way would be to use one of perl's SSL modules
    to send email instead of via plain SMTP).

    So assuming the above jobdonecommand, just save the script as
    /yourserver/rushscripts/jobdonescript.pl


#!/usr/bin/perl -w

###
### SEND EMAIL TO USER(S) WHEN JOB IS DONE
###
###     Invoke this script via 'jobdonecommand'.
###     Any arguments are treated as email addresses.
###
### 03/31/15 erco@(email surpressed) - initial implementation
### 03/31/15 erco@(email surpressed) - added html formatted email messages
###

# Run a command and html-escape all its output
#    $1 - command to run
#    Returns a multiline string of the command's output, html-escaped.
#
sub HtmlEscapeCommand($) {
    my ($cmd) = @_;
    my $out = "";
    foreach my $line ( `$cmd` ) {
        $line =~ s/&/&amp;/g;
        $line =~ s/</&lt;/g;
        $line =~ s/>/&gt;/g;
        $out .= $line;
    }
    return $out;
}

###
### MAIN
###

my $rushdir = ( -d "c:/rush" ) ? "c:/rush" : "/usr/local/rush";
my $rushsendmail = "$rushdir/etc/bin/rushsendmail";

my $from = "rush\@your.dom";
my $to = join(",", @ARGV);		# convert arguments to comma separated list

# USE RUSHSENDMAIL TO DELIVER EMAIL
#    See 'rushsendmail -help' for more info.
#    You can replace this with a perl module or SSL based mail transports..
#
open(MAIL, "|$rushsendmail -t -f$from -p25");

# Mail header that enables HTML content
print MAIL "To: $to\n".
           "From: $from\n".
           "Subject: Rush Job: $ENV{RUSH_JOBID} DONE\n".
           "MIME-Version: 1.0\n".			   # how to do..
           "Content-Type: text/html\n".			   # ..the html formatting.
           "Content-Disposition: inline\n".
           "\n".			                   # empty line ends header
           "<html><body><pre style='font:monospace'>\n";   # start html content, use pre-formatted monospace

# Mail message
#   Since this is HTML content, any "uncontrolled" content must be HTML escaped
#   to prevent HTML special characters (&, <, >) from being mistaken as HTML tags..
#
print MAIL "<B>--- Frame Info Report</B>\n".
           HtmlEscapeCommand("rush -lfi $ENV{RUSH_JOBID}")."\n";
print MAIL "<B>--- Frames Report</B>\n".
           HtmlEscapeCommand("rush -lf $ENV{RUSH_JOBID}")."\n";
print MAIL "<B>--- Job Report</B>\n".
           HtmlEscapeCommand("rush -ljf $ENV{RUSH_JOBID}")."\n";
print MAIL "</pre>\n</body>\n</html>\n";		# ends html content

# Done
close(MAIL);
exit(0);


--
Greg Ercolano, erco@(email surpressed)
Seriss Corporation
Rush Render Queue, http://seriss.com/rush/

Skype: ercolano77
  Tel: (Tel# suppressed)ext.23
  Fax: (Tel# suppressed)
  Cel: (Tel# suppressed)
Path: seriss.com Xref: seriss.com rush.general:2393 NNTP-Posting-Host: 108.74.244.64

Last Next