Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Shell Script to read hive table and send email Post 303042248 by Mi4304 on Thursday 19th of December 2019 01:51:30 PM
Old 12-19-2019
yes countemail.sh is the script and below is the code:

--- Post updated at 07:51 PM ---

complete script
Code:
#!/bin/bash
hive -e 'select * FROM db.table' > output1.csv
sed -i 's/\t/,/g' output1.csv
nawk BEGIN{
FS=","
print  "MIME-Version: 1.0"
print  "Content-Type: text/html"
print  "Content-Disposition: inline"
print  "<HTML>""<TABLE border="1"><TH>project_name</TH><TH>schema_name</TH><TH>table_name</TH><TH>partition_col_name</TH>"}
 {
printf "<TR>"
for(i=1;i<=NF;i++)
printf "<TD>%s</TD>", $i
print "</TR>"
 }
END{
print "</TABLE></BODY></HTML>"
 }''
output1.csv > file.html
echo "file.html" | mailx -s "output" -a file.html email


Last edited by Chubler_XL; 12-19-2019 at 03:55 PM.. Reason: Code Tags Please See YT Video on this: https://youtu.be/4BuPvWJV__k
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to write a shell script to send an email to an id

Hi all, I want to know how to send an email using shell script ..... I tried a command call mail but it did not work.. Please any one reply.. With example if you know thanks.. Madhu (4 Replies)
Discussion started by: madhumathikv
4 Replies

2. Shell Programming and Scripting

make un shell script to send email

Hi, Someone Knows how to obtein a chain from a unix file, but not all the line, for exemple, for this file ,obtein only 902111111 and to keep the value, this value will be used to make a mailx. NF=ALL, SUBJ= FROM: SN=CD, SE=TOPCALL, NA=, N=902111111, N=TCLFI TO: SE=FAX, NA=, C1=... (0 Replies)
Discussion started by: peybol
0 Replies

3. Shell Programming and Scripting

How to send email through shell script

Hi All, I am new to the unix , i have to deliver one script very urgently I have to write a shell script where i have i want to send email to specific email id in this script i want FROM to be parameterized and stored in a variable TO to be parameterized and stored in a variable... (3 Replies)
Discussion started by: nileshbhawsar
3 Replies

4. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

5. Shell Programming and Scripting

How to read specific line of text from a Script and send email notification

Hi ! I am a newbie and never officially wrote a shell script before. The requirement for this script is : 1) Read a file called 'bpm.log' and identify if it has a specific text such as 'this is the text'. Its a static value and that is the only text we need to read. 2) If that... (2 Replies)
Discussion started by: atechcorp
2 Replies

6. Shell Programming and Scripting

Shell script to send an email from the txt file

Hi Friends, Could you guys help me out of this problem... I need to send an email to all the users and the email has to be picked from the text file. text file contains the no. of records like: giridhar 224285 847333 giridhar276@gmail.com ramana 84849 33884 venkata.ramana@gmail.com... (6 Replies)
Discussion started by: giridhar276
6 Replies

7. Shell Programming and Scripting

Help with shell script to send email once

Hi Guys, I have this script which will monitor oracle db process if up or down.And I want it to send email if it's down and the time it's back to online. However my script just keep on sending "Email Up" if the db is up or "Email Down" if the db is down.Is there any way to trap it so that it... (5 Replies)
Discussion started by: d3xt3r
5 Replies

8. Shell Programming and Scripting

how to send html email from shell script

This is my below script which is working fine as it send only plain text email. So My question is- How can I modify my below script to send this as an HTML formatted email? I want to show the text color of this expression `(echo "100*$TEST2/$TEST1" | bc -l)` as `RED` in an email and that can be... (3 Replies)
Discussion started by: raihan26
3 Replies

9. Shell Programming and Scripting

Shell scripting unable to send the sql query data in table in body of email

I have written a shell script that calls below sql file. It is not sending the query data in table in the body of email. spool table_update.html; SELECT * FROM PROCESS_LOG_STATS where process = 'ActivateSubscription'; spool off; exit; Please use code tags next time for your code and data.... (9 Replies)
Discussion started by: Sharanakumar
9 Replies

10. Solaris

How to output the prstat into table and send through email?

Hi how to send below prstat script output into table format and send through email? prstat|awk '{ if ($9 >= 5) print $0 }' (17 Replies)
Discussion started by: tharmendran
17 Replies
HTML::Template(3ruby)													     HTML::Template(3ruby)

NAME
HTML::Template - Ruby extension for HTML::Template DESCRIPTION
This module deals with HTML template by CGI scripts and use a complete selectivity between design and logic easily. You can deal with a nested block, a loop and a conditional expression. Simple example, see below. template file test.html <HTML> <HEAD><TITLE>Test Template</TITLE> <BODY> My Home Directory is <!var:home> <P> My Path is set to <!var:path> </BODY> </HTML> Ruby script require "html/template" tmpl = HTML::Template.new("./test.html") tmpl.param({ 'home' => ENV['HOME'], 'path' => ENV['PATH'] }) print "Content-Type: text/html " print tmpl.output INSTALL
using install.rb % tar xvzf html-template-x.xx.tar.gz % cd html-template-x.xx % ruby install.rb config % ruby install.rb setup % su # ruby install.rb install Template File TAGS
You can use original style tag or valid HTML comment style tag. <!var:PARAMETER_NAME> <!-- var:PARAMETER_NAME --> When you call HTML::Template#param ({PARAMETER_NAME => VAL}), tags will be simply replaced to VAL. <!begin:PARAMETER_NAME> <!end:PARAMETER_NAME> <!-- begin:PARAMETER_NAME --> <!-- end:PARAMETER_NAME --> It allows you to separate a section of text and give it a name It would be able to make them loop or conditional expression. And, it can be nested. <!include:FILE_NAME> <!-- include:FILE_NAME --> A file specified by FILE_NAME is simply inserted to a template file. The template file will be treated as a merged template. If you pass the path param to HTML::Template.new , include file will be searched under the path. HTML
::Template CLASS CLASS METHODS
HTML::Template.new(params = {}) Creates a HTML::Template object. Given a file name to its first argument, use this file as a template. Also you can pass params as Hash. The options are below o filename template filename o path template search path. you can specified as String or Array of String. METHODS
HTML::Template#load(file) Load template file. HTML::Template#set_html(html) Setting up a string as a template. HTML::Template#param(hash = {}) HTML::Template#expand(hash = {}) Specifies a string or a loop by Hash for a substitute. When specifying more than a loop simultaneously, value of the hash becomes an array. HTML::Template#node(name) HTML::Template#loop(name) HTML::Template#cond(name) Stands a loop and a conditional expression specified by <!begin:name><!end:name> Retrieves HTML::TemplateNode object. HTML::Template#output HTML::Template#to_s Returns the final result. HTML
::TemplateNode CLASS This is a class for a loop or a conditional expression. An instance consists of HTML::Template Class and HTML::TemplateNode CLASS. METHODS
HTML::TemplateNode#node(name) Stands a loop or a conditional expression specified by <!begin:name><!end:name> Returns HTML::TemplateNode object. Is only used for nested. HTML::TemplateNode#param(hash = {}) HTML::TemplateNode#expand(hash = {}) HTML::TemplateNode#add(hash = {}) Specifies a string or a loop by Hash for a substitute. If you don't call the method, the block won't be displayed. A LOOP
This sample is a displaying list of environment valiables. <html> <body> <h1>Env List</h1> <hr> <!begin:envlist> <!var:key> : <!var:val><br> <!end:envlist> <hr> </body> </html> # In case of using it with iterator and replace data. require "html/template" tmpl = HTML::Template.new("filename" => "envlist.html") ENV.keys.sort.each do |k| tmpl.node("envlist").param({'key' => k, 'val' => ENV[k] }) end print "Content-Type: text/html " print tmpl.output # In case of giving a loop as an array require "html/template" tmpl = HTML::Template.new("envlist.html") envlist = [] ENV.keys.sort.each do |k| envlist.push({'key' => k, 'val' => ENV[k] }) end tmpl.param({'envlist' => envlist}) print "Content-Type: text/html " print tmpl.output A Conditional Expression <html> <body> <!begin:true> This is True <!var:foo> <hr> <!end:true> <!begin:false> This is False <!var:foo> <hr> <!end:false> </body> </html> require "html/template" tmpl = HTML::Template.new("cond.html") tmpl.param({'true' => {'foo' => 'foobar'} }) print "Content-Type: text/html " print tmpl.output The performed result is below, however, a part not specied with the method isn't displayed. <html> <body> This is True foobar <hr> </body> </html> An attached Sample. env.rb This sample is a simply replacing valiables. envlist.rb This sample is a displaying list of environment valiables. This sample is a case for using with iterator. envlist2.rb Performed result is the same as the envlist.rb.'s. nest.rb A sample of a nested loop. THANKS
English Documentation NAKAYAMA Nao <nao_o@netlaputa.ne.jp> thanks a lot :-) AUTHOR
Copyright 2001 IKEBE Tomohiro This library is free software; you can redistribute it and / or modify it under the same terms as Ruby itself. IKEBE Tomohiro <ikechin@Oxfa.com> June 2002 HTML::Template(3ruby)
All times are GMT -4. The time now is 12:49 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy