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
CONTROL.CTL(5)							File Formats Manual						    CONTROL.CTL(5)

NAME
control.ctl - specify handling of Usenet control messages DESCRIPTION
The file /etc/news/control.ctl is used to determine what action is taken when a control message is received. It is read by the parsecon- trol script, which is called by all the control scripts. (For an explanation of how the control scripts are invoked, see innd(8).) The file consists of a series of lines; blank lines and lines beginning with a number sign (``#'') are ignored. All other lines consist of four fields separated by a colon: message:from:newsgroups:action The first field is the name of the message for which this line is valid. It should be either the name of the control message, or the word ``all'' to mean that it is valid for all messages. The second field is a shell-style pattern that matches the email address of the person posting the message. (The poster's address is first converted to lowercase.) The matching is done using the shell's case statement; see sh (1) for details. If the control message is ``newgroup'' or ``rmgroup'' then the third field specifies the shell-style pattern that must match the group being created or removed. If the control message is of a different type, then this field is ignored. The fourth field specifies what action to take if this line is selected for the message. The following actions are understood: doit The action requested by the control message should be performed. In most cases the control script will also send mail to usenet. doifarg If the control message has an argument, this is treated as a ``doit'' action. If no argument was given, it is treated as a ``mail'' entry. This is used in ``sendsys'' entries script so that a site can request its own newsfeeds(5) entry by posting a ``sendsys mysite'' article. On the other hand, sendsys ``bombs'' ask that the entire newsfeeds file be sent to a forged reply-to address; by using ``doifarg'' such messages will not be processed automatically. doit=file The action is performed, but a log entry is written to the specified log file, file. If file is the word ``mail'' then the record is mailed. A null string is equivalent to /dev/null. A pathname that starts with a slash is taken as the absolute filename to use as the log. All other pathnames are written to /var/log/news/file.log. The log is written by writelog (see newslog(8)). drop No action is taken; the message is ignored. log A one-line log notice is sent to standard error. Innd normally directs this to the file /var/log/news/errlog. log=file A log entry is written to the specified log file, file, which is interpreted as described above. mail A mail message is sent to the news administrator. Lines are matched in order; the last match found in the file is the one that is used. For example, with the following three lines: newgroup:*:*:drop newgroup:tale@*.uu.net:comp.*|misc.*|news.*|rec.*|sci.*|soc.*|talk.*:doit newgroup:kre@munnari.oz.au:aus.*:mail A newgroup coming from ``tale'' at a UUNET machine will be honored if it is in the mainstream Usenet hierarchy. If ``kre'' posts a new- group message creating ``aus.foo'', then mail will be sent. All other newgroup messages are ignored. HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> for InterNetNews. This is revision 1.8, dated 1996/09/06. SEE ALSO
innd(8), newsfeeds(5), scanlogs(8). CONTROL.CTL(5)
All times are GMT -4. The time now is 06:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy