Sponsored Content
Top Forums Shell Programming and Scripting Sending one email for every row as per sql result Post 302328940 by durden_tyler on Thursday 25th of June 2009 01:50:20 PM
Old 06-25-2009
Quote:
Originally Posted by s1a2m3
...
******BUT MY REQUIREMENT IS A SEPRATE EMAIL FOR EVERY LOCKED ID/ROW****
And what are those emails ? E.g. what is the email corresponding to the first id "LJOHNSTON" ? And that corresponding to "CTONOLETE" ? etc.

Code:
...
LJOHNSTON
CTONOLETE
MEDWARDS
MLOVELESS
SALTOSJ
...

Do you want to send the entire log file which contains this -

Code:
$
$ cat locked.log
LJOHNSTON
CTONOLETE
MEDWARDS
MLOVELESS
SALTOSJ
$

to the following list ?

Code:
LJOHNSTON,CTONOLETE,MEDWARDS,MLOVELESS,SALTOSJ

If yes, then you can aggregate the file content into a comma-delimited string like this -

Code:
$
$ addr_list=$(awk '{x=x$0","}END{sub(/,$/, "", x); print x}' locked.log)
$
$ echo $addr_list
LJOHNSTON,CTONOLETE,MEDWARDS,MLOVELESS,SALTOSJ
$

And then use the "addr_list" variable in your mail command.

HTH,
tyler_durden
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to retrieve sql result to unix....

Hi, i would like to retrieve seql result and write it into unix text file like "result.txt" In unix, normally, I type "sql" and get into sql,then type "select....." to run and get the result....then copy and paste into result.txt any possible way to write a script to run it automatically?... (3 Replies)
Discussion started by: happyv
3 Replies

2. Shell Programming and Scripting

formatting the sql select result

Hi, I have about 12 columns and 15 rows to be retrived from sybase isql command through unix. But when i output the sql into a file and see it, the formatting is going for a toss. can someone please suggest how can i get the result correctly in the output file ? Thanks, Sateesh (2 Replies)
Discussion started by: kotasateesh
2 Replies

3. UNIX for Dummies Questions & Answers

Grabbing result of sql command

Hi guys, Is there a way a script can run an SQL statement and dump the results into a variable which can then be used later in the script? Thanks. (3 Replies)
Discussion started by: hern14
3 Replies

4. Shell Programming and Scripting

Sending/append result from CSH script to xls file

Hi, 1st post... Done a quick search for this so apologies if I've missed it. Basically I want to output and and append several values generated by a csh script direct to an xls openoffice file, rather than send to txt file and then physically copy and paste to xls file. Already I send... (4 Replies)
Discussion started by: scottyjock
4 Replies

5. Programming

Send email for each row in a result set

I have SQL giving me output of disabled ids in the system every day. I can send on email for this disabled user list. But I want to send one email for every disabled user or for every row. thank you for your help. Kyle (2 Replies)
Discussion started by: s1a2m3
2 Replies

6. Shell Programming and Scripting

How to format sql result as amount - ksh

I am currently returning an sql result with a number value that I want to format as an amount. The sql runs smoothly on its own, but when run inside my ksh script an error is encountered: ERROR at line 3: ORA-01481: invalid number format model My sql is -- select distinct ... (6 Replies)
Discussion started by: avillanueva
6 Replies

7. UNIX for Dummies Questions & Answers

Assign SQL result in shell variable

Hi im trying to assign the result of the db2 command to a variable inside a shell script... : tab_cnt=`db2 "select count(*) from syscat.tables where tabname = 'ABC' and tabschema = 'MATT01'" |head -4|tail +4|cut -c 11` : echo $tab_cnt when i echo im getting a blank value.. im expecting... (1 Reply)
Discussion started by: matt01
1 Replies

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

9. Shell Programming and Scripting

Get SQL query result to file in putty

How to Get SQL query result to file in putty? I have one SQL query and I want that query output to be redirected to the file. uname -a SunOS XXX 5.8 Generic_117350-58 sun4u sparc SUNW,Sun-Fire-480R Please suggest. (7 Replies)
Discussion started by: pamu
7 Replies

10. Shell Programming and Scripting

Sending sql output to email body with conditional subject line

hi , i have written below piece of code to meet the requirement but i am stuck in the logic here. the requirement are: 1) to send the sql out put to email body with proper formatting. 2) if count_matching = Yes then mail should triggered with the subject line ... (10 Replies)
Discussion started by: itzkashi
10 Replies
Mail::Field::AddrList(3)				User Contributed Perl Documentation				  Mail::Field::AddrList(3)

NAME
Mail::Field::AddrList - object representation of e-mail address lists INHERITANCE
Mail::Field::AddrList is a Mail::Field SYNOPSIS
use Mail::Field::AddrList; $to = Mail::Field->new('To'); $from = Mail::Field->new('From', 'poe@daimi.aau.dk (Peter Orbaek)'); $from->create('foo@bar.com' => 'Mr. Foo', poe => 'Peter'); $from->parse('foo@bar.com (Mr Foo), Peter Orbaek <poe>'); # make a RFC822 header string print $from->stringify()," "; # extract e-mail addresses and names @addresses = $from->addresses(); # strings @names = $from->names(); # strings @addr = $from->addr_list(); # Mail::Address objects (v2.00) # adjoin a new address to the list $from->set_address('foo@bar.com', 'Mr. Foo'); DESCRIPTION
Defines parsing and formatting of address field, for the following fields: "To", "From", "Cc", "Reply-To", and "Sender". All the normally used features of the address field specification of RFC2822 are implemented, but some complex (and therefore hardly ever used) constructs will not be understood. Use Mail::Message::Field::Full in MailBox if you need full RFC compliance. See documentation in the base class. METHODS
See documentation in the base class. Constructors See documentation in the base class. Mail::Field::AddrList->combine(FIELDS) See "Constructors" in Mail::Field Mail::Field::AddrList->extract(TAG, HEAD [, INDEX ]) See "Constructors" in Mail::Field Mail::Field::AddrList->new(TAG [, STRING | OPTIONS]) See "Constructors" in Mail::Field "Fake" constructors See documentation in the base class. $obj->create(OPTIONS) See ""Fake" constructors" in Mail::Field $obj->parse() See ""Fake" constructors" in Mail::Field Accessors See documentation in the base class. $obj->set(OPTIONS) See "Accessors" in Mail::Field $obj->stringify() See "Accessors" in Mail::Field $obj->tag() Mail::Field::AddrList->tag() See "Accessors" in Mail::Field Smart accessors See documentation in the base class. $obj->addr_list() Returns the collected Mail::Address objects. $obj->addresses() Returns a list if email addresses, found in the field content. $obj->names() Returns a list of nicely formatted named, for each of the addresses found in the content. $obj->set_address(EMAIL, NAME) Add/replace an EMAIL address to the field. $obj->text([STRING]) See "Smart accessors" in Mail::Field DETAILS
See documentation in the base class. DIAGNOSTICS
Error: Undefined subroutine <method> called Mail::Field objects use autoloading to compile new functionality. Apparently, the method called is not implemented for the specific class of the field object. SEE ALSO
This module is part of the MailTools distribution, http://perl.overmeer.net/mailtools/. AUTHORS
The MailTools bundle was developed by Graham Barr. Later, Mark Overmeer took over maintenance without commitment to further development. Mail::Cap by Gisle Aas <aas@oslonett.no>. Mail::Field::AddrList by Peter Orbaek <poe@cit.dk>. Mail::Mailer and Mail::Send by Tim Bunce <Tim.Bunce@ig.co.uk>. For other contributors see ChangeLog. LICENSE
Copyrights 1995-2000 Graham Barr <gbarr@pobox.com> and 2001-2007 Mark Overmeer <perl@overmeer.net>. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://www.perl.com/perl/misc/Artistic.html perl v5.18.2 2014-01-05 Mail::Field::AddrList(3)
All times are GMT -4. The time now is 09:45 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy