Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9229143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:29:59+00:00 2026-06-18T05:29:59+00:00

#!/bin/bash ( /usr/src/chkrootkit-$VERSION/chkrootkit ) | # Binary grep ‘INFECTED|Vulnerable’ | # Only get found

  • 0
#!/bin/bash
( /usr/src/chkrootkit-$VERSION/chkrootkit ) | # Binary
grep 'INFECTED|Vulnerable' | # Only get found issues
/bin/mail -s 'CHROOTKIT Weekly Run ($SERVERNAME)' $EMAIL # Send EMail

This still sends e-mails even if nothing is found.

What would be a way to only send if something is grepped?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:30:00+00:00Added an answer on June 18, 2026 at 5:30 am

    This maybe…

    Simply use -E switch in mail command:

    man -Pcol\ -b mail | grep empty
         -E      Don't send messages with an empty body.
    
    
    #!/bin/bash
    ( /usr/src/chkrootkit-$VERSION/chkrootkit ) | # Binary
    grep 'INFECTED|Vulnerable' | # Only get found issues
    /bin/mail -E -s 'CHROOTKIT Weekly Run ($SERVERNAME)' $EMAIL # Send EMail
    

    or place your check in a crontab for automatic processing, for ex once a day:

    @daily  ( /usr/src/chkrootkit-$VERSION/chkrootkit ) | grep 'INFECTED|Vulnerable'
    

    Cron will send a mail if command output something.

    But, after re-reading this

    If there is no need to forward any part of the mail in the alert, there is no need to use the pipe |.

    So you could use condition in this way:

    #!/bin/bash
    ( /usr/src/chkrootkit-$VERSION/chkrootkit ) | # Binary
        grep -q 'INFECTED|Vulnerable' &&
        /bin/mail -s 'CHROOTKIT Weekly Run ($SERVERNAME)' $EMAIL
    

    The -q switch to grep ensure to stay quiet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my crontab is as follows: SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ 01 04 * * *
I was trying to add the mvim shell script to /usr/local/bin form bash as
I wrote the following shell script: #!/bin/bash MAIL=/usr/mail/${LOGNAME:?} . /installations/etl_scripts/etl_job.properties JOB_LOG_FILE_PATH=$JOB_LOG_FILE_PATH export JOB_LOG_FILE_PATH JOB_LOG_FILE_NAME=$JOB_LOG_FILE_NAME
I've got a script like: #!/bin/bash exec /usr/bin/some_binary > /tmp/my.log 2>&1 Problem is that
I have a bash script mysql_cron.sh that runs mysqldump #!/bin/bash /usr/local/mysql/bin/mysqldump -ujoe -ppassword >
I have a simple script which is behaving un-expectedly. path='/usr/local/bin/new_script' content='#!/bin/bash\nls' sudo echo -e
I have a simple bash script: #!/bin/bash JAVA_HOME=/usr EC2_HOME=~/ec2-api echo $EC2_HOME export PATH=$PATH:$EC2_HOME/bin I
I just wrote this backup script: #!/usr/bin/bash # the number of days to do
I'm a noob to shell scripting and am wondering about this: #!/usr/local/bin/bash number=5 echo
$ yum install httpd-devel -bash: /usr/bin/yum: /usr/bin/python: bad interpreter: No such file or directory

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.