Sponsored Content
Top Forums Shell Programming and Scripting Script that gathers specific values from files and puts it into HTML to send e-mail Post 302953627 by shivakid on Monday 31st of August 2015 03:13:39 AM
Old 08-31-2015
Script that gathers specific values from files and puts it into HTML to send e-mail

Hi All,

Sorry for long topic here.

So the drill goes like that, I need a script which gathers different values from different files/locations.

Code:
A_CT=`cat a.dat | awk -F'|' '{print $1}' >> report.txt`
B_CT=`cat b.dat | awk -F'|' '{print $3}' >> report.txt`
C_CT=`cat c.dat | awk -F'|' '{print $5}' >> report.txt`

( this is how im planning to do for taking information i need, there will be 39 files like this, and the columns i print may vary, so im guessing im gonna have to make it this all the way down )

Then lets say i have body.html file where lays only the body of the table, where i have put collumn names and formated the table how i want. I dont have the code, but it's simple. So what i need is to take those values $A_CT, $B_CT , $C_CT and substitute everyhting i need in html body. As this substitution goes, it doesnt have to impact the original body.html file but put a copy of lets say email_out_2015.08.31.html for sending email.

Plus i will have some recipients to send this mail, what's your suggestion do i put recipients straight into script, like:
recipients=one@one.com two@two.com ... etc..
or should i have seperate file name recipients.txt ?
--------------------------------------------------------

The problems I've met already.
If i put the needed values into values.dat file, and try putting them with this line :
Code:
awk 'BEGIN {print "<table>"}
  {print "<tr>"; for(i = 1; i <= NF; i++) print "<td>" $i "</td>"; print "</tr>"}
  END {print "</table>"}' report.txt > report.html

I dont get what i need, i dont get collumn names depending of the filename value has been taken off or, simple html configuration.

So guys any suggestions to do it in simple yet better way, than I'm doing this, cause I know this is an easy one, but since im the starter with UNIX I need your help guys. Any suggestions?

Thanks in advance ;}

Last edited by Don Cragun; 08-31-2015 at 04:38 AM.. Reason: Add CODE and ICODE tags.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Using mail to send HTML emails

Hi, I'm a programmer not a sys admin, so please excuse this if it seems a little out of place, but I think it applies to this forum. When I send my HTML newsletter from the server it comes in as plain text on some email programs and not others. Eudora is fine; Outlook Express, Hotmail, and... (2 Replies)
Discussion started by: dmennis
2 Replies

2. Shell Programming and Scripting

Send an attachment and html text both in the same mail

Hi all, I am working on UNIX (Solaris28). I would like to send an email in which the body will be in html format and, in the same mail, a xls file has to be attached. I have tried this: the file is correctly attached but the body comes as html source and not formatted. If I do not attach the... (4 Replies)
Discussion started by: stefan.yu
4 Replies

3. AIX

Command line/Script to send E-mail with HTML body and binary attachment

I apoligize for the cross-post but I'm not getting much in the way of help in the dummies forum: I'm trying to script sending an e-mail message on an AIX 5.x server with the following requirements: 1. command line switch to specify file name containing message body in HTML format 2. command... (3 Replies)
Discussion started by: G-Man
3 Replies

4. Shell Programming and Scripting

Script needed which will send a mail with attachment files

Hello, I need a shell script which need to send a mail with 4 *.csv files as attachments.Anybody can help me? At present i have a script which is sending only one file as attachments.But i need a script which send 4 files in a shot. #!/bin/ksh /bin/mail xxxx@xx.xom << EOF Subject:... (4 Replies)
Discussion started by: Mar1006
4 Replies

5. Shell Programming and Scripting

Send mail with rich text / HTML with image

Hi, Is it possible to send mail from my HP-Ux system with images, rich text? I would like to program in such a way that I have my company's logo(.jpg) image attached in the mail geeting triggered. I would like to send a rich text/HTML email instead of plain text mail to the recipients. Is it... (2 Replies)
Discussion started by: rythym05
2 Replies

6. 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

7. Shell Programming and Scripting

Unable to send mail with inline html along with attachment. Please help!

The below code is not working. I am able to send only inline html or only attachment. When trying to do both, only inline html is sent without attachment. Please help! #!/bin/ksh (echo "Subject: Test Mail - HTML Format" echo "MIME-Version: 1.0" echo "Content-Type: text/html" echo... (1 Reply)
Discussion started by: thulasidharan2k
1 Replies

8. Shell Programming and Scripting

Script for checking files for last hour and send a mail

Hello, I need to write a script to check the files in one folder , if that folder doesn't have files generated from last 1 hr then we need to send mail to particular persons. So Can you please help me to write script to check the files and send email. Thank you.. (1 Reply)
Discussion started by: archana23
1 Replies

9. Shell Programming and Scripting

Send mail using html tag pre

Need assistance. Trying to send a test.csv file using html tag <PRE> </PRE>. Used to work without any issue . But now gets me and stdin issue. Please give me any suggestions #!/usr/bin/ksh export MAILTO=" <userid>@a.com" export SUBJECT="Test mail " ( echo "Subject: $SUBJECT" echo... (6 Replies)
Discussion started by: ajayram_arya
6 Replies

10. Shell Programming and Scripting

Send multiple HTML output in one mail

HI, I have two scripts which is sending the mail in html format. Script 1: 1.IFILE=/home/home01/Report.csv if #Checks if file exists and readable then if awk -F, '{ T += $13 } END { exit(!T) }' ${IFILE} then awk -F, 'BEGIN{ c=split("3,4,8,9,13", col) print "To:... (0 Replies)
Discussion started by: Vivekit82
0 Replies
IGAWK(1)							 Utility Commands							  IGAWK(1)

NAME
igawk - gawk with include files SYNOPSIS
igawk [ all gawk options ] -f program-file [ -- ] file ... igawk [ all gawk options ] [ -- ] program-text file ... DESCRIPTION
Igawk is a simple shell script that adds the ability to have ``include files'' to gawk(1). AWK programs for igawk are the same as for gawk, except that, in addition, you may have lines like @include getopt.awk in your program to include the file getopt.awk from either the current directory or one of the other directories in the search path. OPTIONS
See gawk(1) for a full description of the AWK language and the options that gawk supports. EXAMPLES
cat << EOF > test.awk @include getopt.awk BEGIN { while (getopt(ARGC, ARGV, "am:q") != -1) ... } EOF igawk -f test.awk SEE ALSO
gawk(1) Effective AWK Programming, Edition 1.0, published by the Free Software Foundation, 1995. AUTHOR
Arnold Robbins (arnold@skeeve.com). Free Software Foundation Nov 3 1999 IGAWK(1)
All times are GMT -4. The time now is 06:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy