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
Courriel::Header::Disposition(3pm)			User Contributed Perl Documentation			Courriel::Header::Disposition(3pm)

NAME
Courriel::Header::Disposition - The content disposition for an email part VERSION
version 0.29 SYNOPSIS
my $disp = $part->content_disposition(); print $disp->is_inline(); print $disp->is_attachment(); print $disp->filename(); my %attr = $disp->attributes(); while ( my ( $k, $v ) = each %attr ) { print "$k => $v "; } DESCRIPTION
This class represents the contents of a "Content-Disposition" header attached to an email part. Such headers indicate whether or not a part should be considered an attachment or should be displayed to the user directly. This header may also include information about the attachment's filename, creation date, etc. Here are some typical headers: Content-Disposition: inline Content-Disposition: multipart/alternative; boundary=abcdefghijk Content-Disposition: attachment; filename="Filename.jpg" Content-Disposition: attachment; filename="foo-bar.jpg"; creation-date="Tue, 31 May 2011 09:41:13 -0700" API
This class supports the following methods: Courriel::Header::Disposition->new_from_value( ... ) This takes two parameters, "name" and "value". The "name" is optional, and defaults to "Content-Disposition". The "value" is parsed and split up into the disposition and attributes. Courriel::Header::Disposition->new( ... ) This method creates a new object. It accepts the following parameters: o name This defaults to 'Content-Type'. o value This is the full header value. o disposition This should usually either be "inline" or "attachment". In theory, the RFCs allow other values. o attributes A hash reference of attributes from the header, such as a filename, creation date, size, etc. The keys are attribute names and the values can either be strings or Courriel::HeaderAttribute objects. Values which are strings will be inflated into objects by the constructor. This is optional, and can be an empty hash reference or omitted entirely. $ct->name() The header name, usually "Content-Disposition". $ct->value() The raw header value. $disp->disposition() Returns the disposition value passed to the constructor. $disp->is_inline() Returns true if the disposition is not equal to "attachment". $disp->is_attachment() Returns true if the disposition is equal to "attachment". $disp->filename() Returns the filename found in the attributes, or "undef". $disp->creation_datetime(), $disp->last_modified_datetime(), $disp->read_datetime() These methods look for a corresponding attribute ("creation-date", etc.) and return a DateTime object representing that attribute's value, if it exists. $disp->attributes() Returns a hash (not a reference) of the attributes passed to the constructor. Attributes are Courriel::HeaderAttribute objects. The keys of the hash are all lower case, though the original casing is preserved in the "name()" returned by the Courriel::HeaderAttribute object. $disp->attribute($key) Given a key, returns the named Courriel::HeaderAttribute object. Obviously, this value can be "undef" if the attribute doesn't exist. Name lookup is case-insensitive. $disp->attribute_value($key) Given a key, returns the named attribute's value as a string. Obviously, this value can be "undef" if the attribute doesn't exist. Name lookup is case-insensitive. The attribute is a Courriel::HeaderAttribute object. $disp->as_header_value() Returns the object as a string suitable for a header value (but not folded). EXTENDS
This class extends Courriel::Header. ROLES
This class does the Courriel::Role::HeaderWithAttributes role. AUTHOR
Dave Rolsky <autarch@urth.org> COPYRIGHT AND LICENSE
This software is Copyright (c) 2012 by Dave Rolsky. This is free software, licensed under: The Artistic License 2.0 (GPL Compatible) perl v5.14.2 2012-03-07 Courriel::Header::Disposition(3pm)
All times are GMT -4. The time now is 07:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy