The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sending HTML attachment through mail sushovan Shell Programming and Scripting 2 07-15-2008 09:47 AM
Send an attachment and html text both in the same mail stefan.yu Shell Programming and Scripting 4 10-26-2006 10:46 PM
sending mail with html content gmchoudary UNIX for Dummies Questions & Answers 2 11-28-2005 08:26 AM
mail: html content RishiPahuja Shell Programming and Scripting 2 10-31-2005 12:43 AM
Using mail to send HTML emails dmennis UNIX for Dummies Questions & Answers 2 06-29-2001 12:42 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-17-2008
Rensen Rensen is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 3
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?

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 (permalink)  
Old 10-19-2008
MrC MrC is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 51
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.
  #3 (permalink)  
Old 10-19-2008
Rensen Rensen is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 3
Quote:
Originally Posted by MrC View Post
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 (permalink)  
Old 10-19-2008
MrC MrC is offline
Registered User
  
 

Join Date: Oct 2008
Posts: 51
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:02 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0