Mail x to HTML


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Mail x to HTML
# 1  
Old 10-17-2008
Mail x to HTML

Hi,
i've build a script, 1: neon_script and the other 2:neon_mailing those to scripts i run with 3:neon_handmatig

After that i get a mail in plain text in my mail box and i want it in html format. I already tried already a several things but nothings seems to work.

Somebody got i idea how i got to fix this?Smilie

bash-2.03$ more neon_script
PHP Code:
:
#! /bin/csh
# Neon - nmslog check
# v0.1 : Richare_NEON: trail version
VERSIE="v0.1"
D1R=/home/richare/neon_instandhouding/neon_script_output
TMPD1R
=/home/richare/neon_instandhouding/neon_script_tmp
TIJD
=`date '+'%d' '%B' '%y' '%T''`
TIJD2=`date "+%Y-%m-%d_%H:%M"`
ZGR3P=/opt/CCOgnu/bin/zgrep
 
 
echo building report ...... please waitthis will take some minutes.....
echo +-----
"$TIJD"----"$versie"---------------------------+ > "$D1R"/"$TIJD2".log
echo +----Stack meldingen ----------------------- vandaag : `grep STACK /var/log/mon/nmslog | wc -l` >> "$D1R"/"$TIJD2".log
echo +----------------------------------------------------------+ >> "$D1R"/"$TIJD2".log
grep 
%STACKMGR-4-STACK_LINK_CHANGE /var/log/mon/nmslog cut -':' -f1,2,3,8,>> "$D1R"/"$TIJD2".log
echo +----------------------------------------------------------+ >> "$D1R"/"$TIJD2".log
echo +----Stack meldingen vorige dag -------- gisteren: `zgrep %STACKMGR-4-STACK_LINK_CHANGE /var/log/mon/nmslog.1.gz | wc -l` >> "$D1R"/"$TIJD2".log
echo +----------------------------------------------------------+ >> "$D1R"/"$TIJD2".log
zgrep 
%STACKMGR-4-STACK_LINK_CHANGE /var/log/mon/nmslog.1.gz cut -':' -f1,2,3,8,>> "$D1R"/"$TIJD2".log
echo +----------------------------------------------------------+ >> "$D1R"/"$TIJD2".log
echo +----------------Port Securty meldingen--------------------+ >> "$D1R"/"$TIJD2".log
echo +----------------------------------------------------------+ >> "$D1R"/"$TIJD2".log
echo +-------Aantal Port Security Meldingen vandaag: `grep %PORT_SECURITY-2-PSECURE /var/log/mon/nmslog|wc -l`------+>> "$D1R"/"$TIJD2".log
echo +----------------------------------------------------------+ >> "$D1R"/"$TIJD2".log
perl 
/home/richare/neon_instandhouding/count_port_security_today |sort +--nr|head ->> "$D1R"/"$TIJD2".log
echo +----------------------------------------------------------+ >> "$D1R"/"$TIJD2".log
echo +-------Aantal Port Security Meldingen gisteren: `zgrep %PORT_SECURITY-2-PSECURE /var/log/mon/nmslog.1.gz|wc -l`------+>> "$D1R"/"$TIJD2".log
echo +----------------------------------------------------------+ >> "$D1R"/"$TIJD2".log
perl 
/home/richare/neon_instandhouding/count_port_security_yesterday |sort +--nr |head ->> "$D1R"/"$TIJD2".log
echo +----------------------------------------------------------+ >> "$D1R"/"$TIJD2".log
echo +-------Aantal Port Security Meldingen eergisteren: `zgrep %PORT_SECURITY-2-PSECURE /var/log/mon/nmslog.2.gz|wc -l`---+>> "$D1R"/"$TIJD2".log
echo +----------------------------------------------------------+ >> "$D1R"/"$TIJD2".log
perl 
/home/richare/neon_instandhouding/count_port_security_daybeforeyesterday |sort +--nr |head ->> "$D1R"/"$TIJD2".log
echo +----------------------------------------------------------+ >> "$D1R"/"$TIJD2".log 
bash-2.03$ more neon_mailing
PHP Code:
#! /bin/csh
# Neon Mailing
# v0.1  : Richare : trail version
set namen=richare
set bestand
=`ls -latr /home/richare/neon_instandhouding/neon_script_output/*.log | cut -d ':' -f2,3 | cut -d ' ' -f2 | tail -1`
perl --pe 's/\.sus\.beheer\.kpn\.net//' $bestand
#perl -i -pe 's/\n/\r\n/' $bestand
/usr/bin/cat "$bestand| /usr/bin/mailx -"Neon Nmslog Analyzer" "$namen
bash-2.03$ more neon_handmatig
PHP Code:
# daily run & mailing(on weekdays only) of neon-parser #
/home/richare/neon_instandhouding/neon_script ##>/dev/null 2>&1
/home/richare/neon_instandhouding/neon_mailing 
# 2  
Old 10-19-2008
While you can certainly place an HTML document wrapper around the plain text output from your scripts, this will be nothing more than the plain text you receive now.

If you want various elements in your reports to be HTML, you must output the HTML tags necessary for the desired formatting. If your report output is consistent, you may be able to post-process the output and insert appropriate HTML tags, wrapping it all up in the proper < html > ... < /html > tags, etc.
MrC
# 3  
Old 10-19-2008
Quote:
Originally Posted by MrC
While you can certainly place an HTML document wrapper around the plain text output from your scripts, this will be nothing more than the plain text you receive now.

If you want various elements in your reports to be HTML, you must output the HTML tags necessary for the desired formatting. If your report output is consistent, you may be able to post-process the output and insert appropriate HTML tags, wrapping it all up in the proper < html > ... < /html > tags, etc.
So you mean (correct me if i'm wrong)

echo <html> > "$D1R"/"$TIJD2".log
echo <b> This text is bold </b> > "$D1R"/"$TIJD2".log
echo +-----"$TIJD"----"$versie"-------- > "$D1R"/"$TIJD2".log
echo </html> "$D1R"/"$TIJD2".log
# 4  
Old 10-19-2008
Yes, that's the idea. But be sure to add all the correct HTML elements (head, title, body).

You can eliminate all those echo's and redirections and instead perform one redirection and write more naturally using a here document:

Code:
$ cat script.sh 
#!/bin/bash

echo Script has started...

cat <<END > /tmp/output
<html>
    <title>This is my HTML</title>
    <body>
        <p>
            This is ...  a  ... test ...
        </p>
        <p>
            $(cd /tmp ; pwd)
        </p>
    </body>
</html>
END

echo Script has completed

$ ./script.sh     
Script has started...
Script has completed

$ cat /tmp/output
<html>
    <title>This is my HTML</title>
    <body>
        <p>
            This is ...  a  ... test ...
        </p>
        <p>
            /tmp
        </p>
    </body>
</html>

Replace my redirection filename /tmp/output with your "$D1R"/"$TIJD2".log. Place your commands where my $(cd /tmp ; pwd) command substitution is. Your commands go inside a $( ... ) command substitution syntax. You do as many of these as you need, or you can place all your commands within a single one, all separated by semicolon's like I have in mine.
MrC
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

HTML mail with Attachment

Hi, I am using the below code: #!/bin/ksh SUBJ="Send mail from Unix with file attachments" TO=sudha.viswanathan@jpmorgan.com CC=sudha.viswanathan@jpmorgan.com ( cat << ! To : ${TO} Subject : ${SUBJ} Cc : ${CC} ! cat << ! MIME-Version: 1.0 Content-Type: text/html `cat... (1 Reply)
Discussion started by: sudvishw
1 Replies

2. Shell Programming and Scripting

Need help in sending html mail with attachment

Hi Everyone, I am facing problems in sending html mail with attachemnt. I will able to send mail with attachment (plain text ) using mailx -s and uuencode command and also html mail without attachment using sendmail option. However I am not able to send html mail along with attachment.Either... (2 Replies)
Discussion started by: karthik adiga
2 Replies

3. Shell Programming and Scripting

HTML mail formating in UNIX

Hi i need to send mail from my Unix server i used the below code. From: TTS.OO.Monitoring.Operations Subject: Error X-Mailer: htmlmail 1.0 Mime-Version: 1.0 Content-Type: text/html; charset=US-ASCII <HTML><head><style type='text/css'> table.altrowstable { font-family:... (6 Replies)
Discussion started by: mohanalakshmi
6 Replies

4. Shell Programming and Scripting

How to mail a html file.?

Hi, Can anyone tell me how to mail a html file in unix? I have a HTML file which contains a table structure, and i want this table to be created in the mail body and mail it. Does anyone have any suggestions. (3 Replies)
Discussion started by: rocky88
3 Replies

5. UNIX for Dummies Questions & Answers

How would i mail in html format?(Formatting Help)

I have written a scripts that checks the load average of server and if it is more than 5 it send a mail describing Current Load Average and High CPU/RAM processes . The problem is I want to send these information in html form .I have done necessary coding to do the same but whenever i try to... (7 Replies)
Discussion started by: pinga123
7 Replies

6. UNIX for Dummies Questions & Answers

How would i mail in html format?(Formatting Help)

I have written a scripts that checks the load average of server and if it is more than 5 it send a mail describing Current Load Average and High CPU/RAM processes . The problem is I want to send these information in html form .I have done necessary coding to do the same but whenever i try to... (0 Replies)
Discussion started by: pinga123
0 Replies

7. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

8. Shell Programming and Scripting

Sending HTML attachment through mail

Hi I am new to unix and scripting.I am trying to send a html file as an attachment. SUBJECT="Type of Exceptions in Application" TO=Sushovan.Samals@gmail.com SPOOLFILE=/data/reg/tlogs/Monitor.html #echo "Send the E-mail message..." uuencode $SPOOLFILE $SPOOLFILE | mailx -s "$SUBJECT" $TO... (2 Replies)
Discussion started by: sushovan
2 Replies

9. UNIX for Dummies Questions & Answers

sending mail with html content

hi, I am new to unix. I need send html content as a mail from my sun-solaris2.6 work station. When I tried that the recipient gets it as html code with all the tags. any solutions? thanx in advance (2 Replies)
Discussion started by: gmchoudary
2 Replies

10. Shell Programming and Scripting

mail: html content

hi guys, am required to prepare a report and mail it, to make it more appealing :p i wish to have content of mail in rich text format i.e html type with mailx how to specify the content type of mail body as html? Thanks in advance!!! rishi (2 Replies)
Discussion started by: RishiPahuja
2 Replies
Login or Register to Ask a Question