Sponsored Content
Top Forums Shell Programming and Scripting [Solved] Sending a HTML email from cli loses formatting. Post 302756073 by cognito on Tuesday 15th of January 2013 06:35:32 AM
Old 01-15-2013
[Solved] Sending a HTML email from cli loses formatting.

Hi,

I have a .sh file, to email a report of our backups from a linux machine. It looks like this (minus a few bits):

Code:
echo "HELO $host.$domain"
sleep 1
echo "mail from: vdrreport@$domain"
sleep 1
echo "rcpt to:$mailto"
sleep 1
echo "data"
sleep 1
echo "subject: $host VDR-Report $(date +"%Y.%m.%d %H:%M")"
sleep 1
echo "from: "vdrreport@$domain
sleep 1
echo "to:$mailto"
sleep 1
echo "Mime-Version: 1.0;"
sleep 1
echo "Content-Type: text/html; charset="ISO-8859-1";"
sleep 1
echo "Content-Transfer-Encoding: 7bit;"
sleep 1
sleep 1
echo "##### Backup overview ($succ successfull jobs) #####"
sleep 1
echo "<p> "
sleep 1
  if [ -f /root/oldbackup.out ]
    then
      cat grep "Task completed" /root/oldbackup.out | grep $today
    else
      echo No list for backups found!
  fi
sleep 1
echo "<p/>"
sleep 1
echo " "
sleep 1
echo "."
sleep 1
echo "QUIT"
) | telnet $smtphost.$domain 25

This sends a html email, but without any formatting for the log file that has been cat out.

##### Backup overview (57 successfull jobs) #####
1/11/2013 12:01:52 AM: Performing incremental back up of disk Productci/Productci-flat.vmdk 1/11/2013 12:07:26 AM: Removed snapshot_datarecovery_ 1/11/2013 12:07:26 AM: Task completed successfully 1/11/2013 12:07:26 AM: Completed: 5 files, 25.1 GB 1/11/2013 12:07:26 AM: Performance: 4585.0 MB/minute 1/11/2013 12:07:26 AM: Duration: 00:07:18 (00:01:43 idle/loading/preparing) 1/11/2013 12:01:07 AM: Performing incremental back up of disk tflcrowndev1/tflcrowndev1-000002-flat.vmdk 1/11/2013 12:09:21 AM: Removed snapshot_datarecovery_ 1/11/2013 12:09:21 AM: Task completed successfully

If i just send it as plain text, it appears fine:

Code:
11/28/2012 4:01:44 PM: Starting incremental integrity check
11/28/2012 4:04:10 PM: Task completed successfully

11/29/2012 4:24:35 PM: Starting incremental integrity check
11/29/2012 4:27:45 PM: Task completed successfully

Can i get my email to send as html and keep the same formatting as plain text?

Cheers.

Last edited by radoulov; 01-15-2013 at 10:19 AM.. Reason: Marked as solved.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

formatting output in html

hello all. I was hoping someone may have an idea or two. I'm throwing together a shell script that does a lot of application and system level data collection. The idea is is you run it before/after restarting an application for later analysis. A lot of stuff is collected... resource stats,... (4 Replies)
Discussion started by: ebbtide
4 Replies

2. Shell Programming and Scripting

Displaying file in html loses format

I have a bash script to output the contents of a text file to html. Everything outputs ok, except this: ###################################################################### # # # PRIVATE/PROPRIETARY # # # # ANY UNAUTHORIZED ACCESS TO, OR MISUSE OF ABC COMPANY # # SYSTEMS OR DATA MAY... (2 Replies)
Discussion started by: numele
2 Replies

3. UNIX Desktop Questions & Answers

Grep result loses formatting

I am searching for a string in a file and then redirecting the contents in another file... however the formatting is not preserved.. Can you please help me on this ... (5 Replies)
Discussion started by: blackeyed
5 Replies

4. Shell Programming and Scripting

Sending HTML Email through mailx

Hi, I am trying to send html email using mailx like follow on sh shell (Bourne) on HP-UX: mailx -s "Test HTML output in outlook MIME-Version: 1.0 Content-Type: text/html" receiver@host.com < file.txt Content of file.txt are as follows: <html> <h2>An important link to look at!</h2>... (3 Replies)
Discussion started by: manubatham20
3 Replies

5. Shell Programming and Scripting

Using top command to email if process is exceeding 25% and sending an email alert if so

This is my first time writing a script and Im having some trouble, Im trying to use the top command to monitor processes and the amount of CPU usage they require, my aim is to get an email if a process takes over a certain percentage of CPU usage I tried grep Obviosly that hasnt worked, Any... (8 Replies)
Discussion started by: jay02
8 Replies

6. UNIX for Dummies Questions & Answers

Sending html email with html attachment

Hello, I have a script which is sending an html file as an attachment. #!/usr/bin/ksh export MAILTO="user@company.com" export CONTENT="/usr/tmp/file.html" export SUBJECT="EmailSubject" ( echo "Subject: $SUBJECT" echo "MIME-Version: 1.0" echo "Content-Type: text/html" echo... (0 Replies)
Discussion started by: sreenathkg
0 Replies

7. HP-UX

[Solved] HTML Email output issue

Hi All, I am facing issue while trying to send an HTML email using my HP-UX server. I am trying to send some color codes to be drawn in the output, but in the output the correct color is not appearing. It is appearing some shades of green all the time. I referred to w3 website for the color... (5 Replies)
Discussion started by: chpsam
5 Replies

8. Shell Programming and Scripting

Sending HTML Email

1) Can you please provide me with a best example of how to send an HTML email via mutt or mail or send email commands using bash shell. 2) I tried below but i am not able to get the variable values in the HTML email output. (cat <<-EOT <html> <head><title></title> </head> <body> <p>Hello,... (9 Replies)
Discussion started by: Ariean
9 Replies

9. Shell Programming and Scripting

HTML not coming while sending using email

echo "$1" > test.txt awk 'BEGIN{ FS="|" print "MIME-Version: 1.0" print "Content-Type: text/html" print "Content-Disposition: inline" print "<HTML>""<TABLE border="1"><TH>Heading1</TH><TH>Heading2</TH><TH>Heading3</TH>" } { printf "<TR>" for(i=1;i<=NF;i++) printf "<TD>%s</TD>", $i... (2 Replies)
Discussion started by: ATWC
2 Replies

10. Shell Programming and Scripting

HTML formatting in shellscript

I have written one script which connects to MYSQL database, fires one select query and send the results over an email, if there is any Output. But the Output which I am receiving over email is in text format. I need to get it dispalyed in tabular format to ensure better readability. Below is... (3 Replies)
Discussion started by: Sambit Sahu
3 Replies
SYSTEMD-SUSPEND.SERVICE(8)				      systemd-suspend.service					SYSTEMD-SUSPEND.SERVICE(8)

NAME
systemd-suspend.service, systemd-hibernate.service, systemd-hybrid-sleep.service, systemd-suspend-then-hibernate.service, systemd-sleep - System sleep state logic SYNOPSIS
systemd-suspend.service systemd-hibernate.service systemd-hybrid-sleep.service systemd-suspend-then-hibernate.service /lib/systemd/system-sleep DESCRIPTION
systemd-suspend.service is a system service that is pulled in by suspend.target and is responsible for the actual system suspend. Similarly, systemd-hibernate.service is pulled in by hibernate.target to execute the actual hibernation. Finally, systemd-hybrid-sleep.service is pulled in by hybrid-sleep.target to execute hybrid hibernation with system suspend and pulled in by suspend-then-hibernate.target to execute system suspend with a timeout that will activate hibernate later. Immediately before entering system suspend and/or hibernation systemd-suspend.service (and the other mentioned units, respectively) will run all executables in /lib/systemd/system-sleep/ and pass two arguments to them. The first argument will be "pre", the second either "suspend", "hibernate", "hybrid-sleep", or "suspend-then-hibernate" depending on the chosen action. Immediately after leaving system suspend and/or hibernation the same executables are run, but the first argument is now "post". All executables in this directory are executed in parallel, and execution of the action is not continued until all executables have finished. Note that scripts or binaries dropped in /lib/systemd/system-sleep/ are intended for local use only and should be considered hacks. If applications want to react to system suspend/hibernation and resume, they should rather use the Inhibitor interface[1]. Note that systemd-suspend.service, systemd-hibernate.service, and systemd-hybrid-sleep.service systemd-suspend-then-hibernate.service should never be executed directly. Instead, trigger system sleep states with a command such as "systemctl suspend" or similar. Internally, this service will echo a string like "mem" into /sys/power/state, to trigger the actual system suspend. What exactly is written where can be configured in the "[Sleep]" section of /etc/systemd/sleep.conf or a sleep.conf.d file. See systemd-sleep.conf(5). OPTIONS
systemd-sleep understands the following commands: -h, --help Print a short help text and exit. --version Print a short version string and exit. suspend, hibernate, hybrid-sleep, suspend-then-hibernate Suspend, hibernate, suspend then hibernate, or put the system to hybrid sleep. SEE ALSO
systemd-sleep.conf(5), systemd(1), systemctl(1), systemd.special(7), systemd-halt.service(8) NOTES
1. Inhibitor interface https://www.freedesktop.org/wiki/Software/systemd/inhibit systemd 237 SYSTEMD-SUSPEND.SERVICE(8)
All times are GMT -4. The time now is 05:10 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy