Merge Text with space into once cell and send email out

Please help!!

This code works perfect but the only problem I am having is that is treats eg SQL Developer as separate cell/column which makes the formatting bad. I want to put SQL Developer in one cell. I attached a sample of how the output looks like.

report.txt

USERNAME             OSUSER       MACHINE              PROGRAM                                 COUNT(*)             
-------------------- ------------ -------------------- -------------------------                              ----------             
xxxxxxx                       xxxxxxx      xxxxxxx         	    Toad.exe                                       5             
xxxxxxx                       xxxxxxx      xxxxxxx                     SQL Developer                          4 
awk ' BEGIN {
 print "From: from@x.com"
 print "To: to@x.com"
 print "MIME-Version: 1.0"
 print "Content-Type: text/html"
 print "Subject: Your Subject"
 print "<html><body><table border=1 cellspacing=2 cellpadding=3>"
 print "<tr>"
 print "</tr>"
} {
 print "<tr>"
 print "<td>"$1"</td>";
 print "<td>"$2"</td>";
 print "<td>"$3"</td>";
 print "<td>"$4"</td>";
 print "<td>"$5"</td>";
 print "</tr>"
} END {
 print "</table></body></html>"
} ' report.txt | sendmail -t

Please provide your exact SQL query and 10 lines of the exact output of that command. You can mask any data which is confidential or sensitive; but you need to show your exact query and exact output.

Thanks.

OBTW, these table attributes are obsolete:

border=1 cellspacing=2 cellpadding=3

Where are you getting this example HTML from?

The cause of your problem is the field contains a "field separator" correctly interpreted by awk . man mawk :

If report.txt had e.g. <TAB>s as field separators, you'd be lucky - just redefine awk 's FS variable to be <TAB> only.

If not, you can

  • modify the report to use a different column separator.
  • have the report replace the spaces in a field with something unambigious (e.g. _ ).
  • have field 4 treated differently by awk (if it's always field 4 that could have the problem).

Thanks all for you help. I fixed it by just adding

set markup html on entmap off table 'BORDER="2" ' 

to my sql file. That was the only thing I was missing

FYI:

In other words, as I mentioned earlier, the "border" attribute is obsolete.

You should use CSS, not obsolete HTML elements.