Sponsored Content
Top Forums Shell Programming and Scripting HTML formatting in shellscript Post 303002074 by Sambit Sahu on Thursday 17th of August 2017 04:52:50 AM
Old 08-17-2017
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 the script I have tried and the sample email what I am receiving:

Code:
#!/bin/bash
#MAILTO="sambit.sahu@niceactimize.com"
mysql test -e "select c.CenterID,a.MIC,c.ExchangeName,a.CountryCode,a.EventDate,a.EventDayOfWeek,b.eventName from exch_calendar_event a left join exch_calendar_eventName b on a.EventID=b.ID left join exch_calendar_mic c on a.MIC=c.MIC where EventDate=DATE_FORMAT(20170811,'%Y%m%d') order by a.MIC;" > file.tmp
if [ -s file.tmp ]
then
       mailx -s "Holiday" $MAILTO  <file.tmp
fi
rm file.tmp


Below is the output, what I am receiving over mail. I want to convert it into tabular format with adding HTML formatting.

Code:
CenterID    MIC    ExchangeName    CountryCode    EventDate    EventDayOfWeek    eventName
706    XTKS    Tokyo Stock Exchange    JP    20170811    Fri    Mountain Day


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 08-17-2017 at 06:08 AM.. Reason: Added CODE tags.
 

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. UNIX for Dummies Questions & Answers

How do I extract text only from html file without HTML tag

I have a html file called myfile. If I simply put "cat myfile.html" in UNIX, it shows all the html tags like <a href=r/26><img src="http://www>. But I want to extract only text part. Same problem happens in "type" command in MS-DOS. I know you can do it by opening it in Internet Explorer,... (4 Replies)
Discussion started by: los111
4 Replies

3. UNIX for Advanced & Expert Users

shellinabox/html help to insert a keypress with an html button

I am trying to use shellinabox as a terminal emulator. Everything is working except there seems to be no way to simulate an F14 button press in shellinabox. I am already embedding shellinabox in an html page so Im am wondering if there is a way to make an html/js button that will pass F14 to the... (0 Replies)
Discussion started by: syadnom
0 Replies

4. Red Hat

Send HTML body and HTML attachment using MUTT command

Hi there.. I need a proper "mutt" command to send a mail with html body and html attachment at a time. Also if possible let me know the other commands to do this task. Please help me.. (2 Replies)
Discussion started by: vickramshetty
2 Replies

5. Shell Programming and Scripting

html formatting using awk

Hi I have a file as given below: <table border=1> <TR><TH>Script Name</TH><TH>CVS Status</TH><TH>Script Location</TH></TR> <TR><TD><CENTER>Work Area: /home/ustst/</CENTER></TD></TR> <TR><TD><CENTER>admin_export.sh</CENTER></TD><TD><CENTER>Locally... (1 Reply)
Discussion started by: sudvishw
1 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 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

8. Shell Programming and Scripting

Removing all except couple of html tags from html file

I tried to find elegant (or at least simple) way to remove all but couple of html tags from html file, but all examples I found dealt with removing all the tags. The logic of the script would be: - if there is <li> or <ul> on the line, do nothing (=write same line to output) - if there is:... (0 Replies)
Discussion started by: juubuntu
0 Replies

9. UNIX for Advanced & Expert Users

Mutt for html body and multiple html & pdf attachments

Hi all: Been racking my brain on this for the last couple of days and what has been most frustrating is that this is the last piece I need to complete a project. There are numerous posts discussing mutt in this forum and others but I have been unable to find similar issues. Running with... (1 Reply)
Discussion started by: raggmopp
1 Replies

10. Shell Programming and Scripting

[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): 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... (2 Replies)
Discussion started by: cognito
2 Replies
MIC-LIVECD-ISO-TO-DISK(1)				      General Commands Manual					 MIC-LIVECD-ISO-TO-DISK(1)

NAME
mic-livecd-iso-to-disk - Convert a livecd image to a live USB image then write to a USB disk or partition SYNOPSIS
mic-livecd-iso-to-disk [--reset-mbr] [--noverify] [--overlay-size-mb <size>] [--home-size-mb <size>] [--unencrypted-home] <isopath> [usbstick device] <isopath> is your livecd image path name, [usbstick device] is optional, if not provided, it will detect automatically and ask you to select. DESCRIPTION
mic-livecd-iso-to-disk can convert a livecd image to a live USB image and write it to a USB disk or partition, it is different from mic- image-writer which is just a safer dd with progress bar. mic-livecd-iso-to-disk can detect all the removable USB disks and let you select one of them, if you didn't insert any USB disk, it will ask you to insert until a USB disk is available, it can decide if your USB disk need to be formated and if your USB disk has an appropriate partition for this livecd image, all the operations are interactive and have warnings f they will damage your old data on your USB disk. mic-image-manager has a GUI tool for it. OPTIONS
--reset-mbr Set MBR on your USB disk --noverify Don't verify your livecd image --overlay-size-mb Specify overlay size, the default size is 64 MB --home-size-mb Specify home size, the default is 0 EXAMPLES
Write a Molib live image to your USB disk: mic-livecd-iso-to-disk your-2.1-final.img EXIT STATUS
mic-livecd-iso-to-disk returns a zero exist status if it succeeds, otherwise return non-zero and print error message. AUTHOR
Yi Yang, Anas Nashif, Jianfeng Ding SEE ALSO
mic-image-creator(1), mic-convertor(1), mic-chroot(1), mic-image-writer(1), mic-image-manager(1) perl v5.12.3 2011-05-31 MIC-LIVECD-ISO-TO-DISK(1)
All times are GMT -4. The time now is 08:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy