Unix/Linux Go Back    


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

UNIX for Beginners Questions & Answers


Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 10-03-2017   -   Original Discussion by arunkumar_mca
arunkumar_mca's Unix or Linux Image
arunkumar_mca arunkumar_mca is offline
Registered User
 
Join Date: Oct 2004
Last Activity: 11 December 2017, 10:01 AM EST
Posts: 395
Thanks: 61
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.




Code:
 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
    #2  
Old Unix and Linux 10-03-2017   -   Original Discussion by arunkumar_mca
Corona688's Unix or Linux Image
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 22 January 2018, 1:38 PM EST
Location: Saskatchewan
Posts: 22,574
Thanks: 1,163
Thanked 4,293 Times in 3,961 Posts


Code:
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
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 08:47 AM
Ksh: Send a mail in case grep finds something Cochise Shell Programming and Scripting 10 09-25-2014 02:26 AM
Group the records based on empno and send mail kiranparsha UNIX for Advanced & Expert Users 2 03-19-2013 06:07 AM
Send mail based on a group Max499 Shell Programming and Scripting 8 01-24-2013 04:52 PM
How to send a mail in unix--Please read the description electroon Shell Programming and Scripting 2 01-03-2008 02:40 AM



All times are GMT -4. The time now is 06:17 AM.