UNIX for Beginners Questions & Answers

If you're not sure where to post a Unix or Linux question, post it here. All unix and Linux beginners welcome in this forum!

Read a file and send mail based on grep

👤 Login to reply

Old 10-03-2017
arunkumar_mca arunkumar_mca is offline
Registered User
Join Date: Oct 2004
Last Activity: 22 June 2018, 11:25 AM EDT
Posts: 416
Thanks: 81
Thanked 2 Times in 2 Posts
Read a file and send mail based on grep

Hi All,

I am having a job and I need to send email when the job is running. On any other case (success,fail) I don't needed to send email. I check with BMC they told they dont have that in the version I am using.

So I created a dependent job and grepped for the status and sent email. My issue is even the job is success it is send empty email.

 jobdefn  wat_job | grep RU | mailx

If the job is success also it is sending an empty email. I put the above command on the depend job of wat_job. basically I want to mailx to execute only if grep RU is success and on a single command . is that possible ?

thanks in Advance.
Sponsored Links
Old 10-03-2017
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
Join Date: Aug 2005
Last Activity: 20 July 2018, 3:26 PM EDT
Location: Saskatchewan
Posts: 22,727
Thanks: 1,194
Thanked 4,351 Times in 4,006 Posts
jobdefn wat_job | grep -q RU && echo "message" | mailx

The Following User Says Thank You to Corona688 For This Useful Post:
arunkumar_mca (10-04-2017)
Sponsored Links
👤 Login to reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Grep the 'not running' jobs and will send the update in mail with its name(job) learner987 UNIX for Beginners Questions & Answers 1 03-16-2016 07:47 AM
Ksh: Send a mail in case grep finds something Cochise Shell Programming and Scripting 10 09-25-2014 01:26 AM
Group the records based on empno and send mail kiranparsha UNIX for Advanced & Expert Users 2 03-19-2013 05:07 AM
Send mail based on a group Max499 Shell Programming and Scripting 8 01-24-2013 03:52 PM
How to send a mail in unix--Please read the description electroon Shell Programming and Scripting 2 01-03-2008 01:40 AM

All times are GMT -4. The time now is 12:48 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
Show Password

Not a Forum Member?
Forgot Password?