Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

Check servers availability using bash script

echo -e "Enter result file name: c"
read -r fileloc
touch ~/$fileloc
truncate -s 0 ~/$fileloc

echo -e "Enter server file list: c"
read -r serverloc

for i in `cat $serverloc`
do

ping $i -c 1 >> ~/$fileloc
valid=`echo $?`

if [[ $valid -ge 1 ]]; then
        echo "$i host is not reachable"
else
        echo "$i host is up and running"
fi
done
vim ~/$fileloc
 
PREVIOUS NEXT
Tagged: #Check #servers #availability #bash #script
ADD COMMENT
Topic
Name
4+6 =