Bash script Check If Host Is Reachable

3
(1)

Bash Check If Host Is Reachable

#!/bin/bash
host=$1
ping -c 1 $host > /dev/null
if [ $? -eq 0 ]; then
  echo "Host $host is reachable."
else
  echo "Host $host is not reachable."
fi
 

Similar Posts:

726

How useful was this post?

Click on a star to rate it!

Average rating 3 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top