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 7935243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:51:43+00:00 2026-06-03T21:51:43+00:00

#!/bin/bash #James Kenaley 20120513 #Server Monitor Script while read -r name ip content do

  • 0
#!/bin/bash
#James Kenaley 20120513
#Server Monitor Script
while read -r name ip content
do
    ip_status=`ping -w1 $ip | grep -c "100%"`
    web_status=`nmap -n -PN -p 80 $ip | grep -c open`
    ssh_status=`nmap -n -PN -p 22 $ip | grep -c open`
    content_status=`diff <(curl -s $ip | md5sum) <(cat $content) | grep -c -e "<" -e ">"`
    if [ $web_status -eq 1 ]
    then
            echo "The webserver is running on $name @ $ip"
    else
            echo "  The webserver is offline on $name @ $ip"
    fi

    if [ $ssh_status -eq 1 ]
    then
            echo "SSH is enabled on $name @ $ip"
    else
            echo "  SSH has been disabled on $name @ $ip"
    fi

    if [ $content_change -gt 0 ]
    then
            echo "  The content has changed on $name's webserver"
    else
            echo "The content is the same"
    fi
done < server.list

I know the easy way would just be to compare the content in another variable but i REALLY want to keep the comparison in one line. So if anyone can help me I would greatly appreciate it

  • 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-03T21:51:44+00:00Added an answer on June 3, 2026 at 9:51 pm

    diff and grep both support -q. Use them directly in the if statements instead of capturing their output and comparing it separately.

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

Sidebar

Related Questions

I have the following bash script: #!/bin/bash FILE=p.txt while read line; do export http_proxy=http://$line
If I have a Bash script like: #!/bin/bash f() { # echo function name,
I am facing with the following bash script: #! /bin/bash processname=$1 x=1 while [
Say the following Bash script: #!/bin/bash export TEXTDOMAINDIR=./locale export TEXTDOMAIN=test-gettext-read . gettext.sh echo -n
I have this bash script here #!/bin/bash find /Users/ -name *.mov -o -name *.flv
#!/bin/bash -x echo Enter file name: read fileName fileName=`pwd`/$fileName if [ -f $fileName ];
#!/bin/bash echo Please enter your Host Name read hname echo You have entered $hname,
#!bin/bash echo enter your password : read password passlength=$(echo ${#password}) if [ $passlength -le
Linux bash script: #!/bin/bash function Print() { echo $1 } var=* Print $var Execution
Suppose a shell script (/bin/sh or /bin/bash) contained several commands. How can I cleanly

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.