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.

jobdefn wat_job | grep -q RU && echo "message" | mailx 
1 Like