Sponsored Content
Top Forums Shell Programming and Scripting help with script to send email and if subject line match is found Post 302435537 by axdelg on Wednesday 7th of July 2010 03:23:23 PM
Old 07-07-2010
help with script to send email and if subject line match is found

Help with script that will check log, then find a match is found, add that as the subject line.

1. The script will always run as a deamon.. and scan the event.log file
2. when a new 101 line is added to the event.log file, have the script check position 5,6 and 7 which is the job name, which is LOK
3. if position 5,6 and 7 is in a the hspm_table.txt then add the information on the right CGI CLAIMS in the email subject line of the email.

Event.log

Code:
 
101 WDC5337A 0AAAAAAAAAAAH54R NC_TLF2_SLEEP10 WDC5337A 1294422 5 NC_TLF2_SLEEP10 maestrot sleeep\0405400 -32768 1 2010070712140000 0 +++ 6453 1 1277734500 0 0 0 127 0AAAAAAAAAAAH54R 6453 TEST_JSA 2010062814150000 v.4 NONE NONE 4 NONE NONE NONE 0 0 0 0 0 NONE
101 LILTST505 0AAAAAAAAAAAHXH2 CU_MLOK_IAM_INTAKE_PROCESS_LILVSGT4W LILVSGT4W 558803 5 CU_MLOK_IAM_INTAKE_PROCESS_LILVSGT4W silver\REED_APP e:\FMLA\CIGNA_CGI_Intake_Processor.BAT 0015 10 2010070712300000 0 +++ 7748 1 1278505800 0 60 0 1 0AAAAAAAAAAAHXH2 5973 MLOKIAM1 2010070612110000 v.4 NONE NONE 4 NONE NONE NONE 0 0 0 0 0 NONE



hspm_table.txt

Code:
 
LF2 PROD CNTL ADMIN SERV
LKB PROD SVC DB2 DBA
LKG PROD SVC DB2 DBA
LKJ AMP CGI AQUISITION
LOK CGI CLAIMS


Here is my script that only sends the email, but does not check the hspm_table.txt to find a match.

Code:
 
#!/bin/sh -x 
DATE=`date` 
TWSHOME=/usr/lib/maestro/ 
EVENTLOG=event.log 
MAILING="email@fromtable" 
tail -f -n 1 $TWSHOME/$EVENTLOG | while read line ; do echo "$line" | grep '^101' ; if [ $? -eq 0 ]; then echo "$line" | awk '{print "Mail sent by checkevent.sh script""\n""\n""A Job has abended.""\n""Please check information below:""\n""Workstation:",$2,"\n""Job Stream:",$3,"\n""Job Name:",$4"\n""Job ID:",$6,"\n""Job Status:",$7,"\n""Scheduled Time:",$26,"\n""Actual Start:",$13"\n""\n""Thanks""\n""TWS team."}' | mail -s "Email sent from `hostname` at $DATE" $MAILING ; fi ; done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

if match found go to a particular line in perl

Hello Experts, I am newbie to perl, just curious to know how to do the following in perl. suppose I ve a txt file like below. when it founds "*Main Start" Then go to "*Main End,,,,,,,," patteren and just collect the number from the previous line of "*Main End,,,,,,," pattern . In my... (17 Replies)
Discussion started by: user_prady
17 Replies

2. Shell Programming and Scripting

Run a script based on the subject line of the email

Hi, I need help in running a script that would pull info from an email subject line and run a script (foo.sh). I'm pretty sure after a bit of googling that this is possible in several ways. but none was pretty clear on how to accomplish it. The part that I really need help with is getting the... (5 Replies)
Discussion started by: satekn
5 Replies

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

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

5. UNIX for Dummies Questions & Answers

Display n lines after match found and other line

I have a file like this DoctorName Address1 Address2 DOB InsuredName Address1 Address2 DOB PatientName Address1 Address2 DOB ClaimNo1 DoctorName Address1 Address2 DOB InsuredName (2 Replies)
Discussion started by: nsuresh316
2 Replies

6. Shell Programming and Scripting

Displaying text till pattern match found in a line

Hi All, From the below line if we want to display all the text till found pattern dot/. I was trying with the below code but couldn't able to print text before the pattern. it display texts which is found after pattern. awk '/assed/{print;getline;print}' file_name | sed 's/^*. *//' input... (4 Replies)
Discussion started by: Optimus81
4 Replies

7. Shell Programming and Scripting

How to print the entire line if the mentioned match is found?

Hello Everyone, I have a file with 5 fields in each line just like mentioned below. Also the 4th field is time elapsed(hh:mm:ss) since the process is running xyz abc status 23:00:00 idle abc def status 24:00:00 idle def gji status 27:00:02 idle fgh gty status 00:00:00 idle Here I... (8 Replies)
Discussion started by: rahul2662
8 Replies

8. Shell Programming and Scripting

Sendemail how to send an email with a subject variable

Hi,:) I try this : #!/bin/bash sender="me@example.com" recipient="you@example.com" subject="TEST FILE" server="0.0.0.0" file=$(cat file.txt) /usr/bin/sendemail -f $sender -t $recipient -u $subject -m $file My file.txt: BLABLALA BLABLABLA (7 Replies)
Discussion started by: Arnaudh78
7 Replies

9. Shell Programming and Scripting

Add comment on last line if found match

Hi All, totally new on it , normally use it for just 1 line. i'm looking for help. i'm have 2 file. file 1 : -------------------------------------------------- c12 c1 c3 -------------------------------------------------- file 2: other content ... (10 Replies)
Discussion started by: kttan
10 Replies

10. UNIX for Beginners Questions & Answers

Modify text file if found multiple pattern match for every line.

Looking for help, i have input file like below and want to modify to expected output, if can without create additional file, hope can direct modify it. have 2 thing need do. 1st is adding a word (testplan generation off) after ! ! IPG: Tue Aug 07 14:31:17 2018 2nd is adding... (16 Replies)
Discussion started by: kttan
16 Replies
PMAILQ(8)																 PMAILQ(8)

NAME
pmailq - Postfix MAIL Queue manager SYNOPSIS
pmailq [OPTION]... [COMMAND] pmailq --help DESCRIPTION
pmailq parses the output of mailq command from postfix (ie: postqueue -p). It permits to perform some actions on a group of entries in queue (like removing or displaying them in a machine readable format). They are selected by applying filters (wildcards are allowed) on criterias like email address, error message from SMTP server, message size, mail status in queue. COMMANDS
Action to perform on selected entries. list (default command) Show a detailed listing of the selected entries. parse Show a listing of the selected entries in a machine readable format. del Delete (via postsuper -d) the selected entries. OPTIONS
-e PATTERN, --email=PATTERN Select entries in queue with email matching PATTERN (PATTERN accepts wildcards). -m PATTERN, --msg=PATTERN Select entries in queue with error message matching PATTERN (PATTERN accepts wildcards). -l SIZE, --size-lower=SIZE Select entries in queue with size lower than SIZE bytes. -u SIZE, --size-upper=SIZE Select entries in queue with size upper than SIZE bytes. -a Select 'active' entries in queue. -o Select 'on hold' entries in queue. --version Show program's version number and exit. -h, --help Show this help message and exit. EXAMPLES
Example 1: display all the entries in queue sent to an email address matching "*@example.com*" with a size between 3000 and 3200 bytes in a machine readable format: # pmailq -u 3000 -l 3200 -e "*@example.com" parse 7E75214643A4|Fri Aug 31|3154|1|0|edgar@example.com B0BDE146B640|Thu Aug 30|3199|1|0|paul@example.com B587E146B675|Wed Aug 29|3065|0|0|paul@example.com CF3C514656E4|Wed Aug 29|3161|0|0|abuse@example.com / / / queue id date size on hold (or not) active (or not) Example 2: remove all mails in queue not sent because of a connection time out: # pmailq -m "*connection*timed*out" del deleting 00CF514616D3 [OK] deleting 12D911461924 [OK] deleting 269EF1461CA9 [OK] deleting 288DF1461CA0 [OK] deleting 3B3901460F62 [OK] deleting 3AE58147019F [OK] SEE ALSO
postsuper(1) privileged queue operations, postqueue(1) mail queue control AUTHOR
Emmanuel Bouthenot <kolter@openics.org> COPYRIGHT AND LICENSE
Copyright 2007-2011 by Emmanuel Bouthenot <kolter@openics.org> This program is released under the "do What The Fuck you want to Public Licence" Version 2, as published by Sam Hocevar. See http://sam.zoy.org/wtfpl/COPYING for more details. 2011-01-05 PMAILQ(8)
All times are GMT -4. The time now is 02:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy