1

I have the following script

filename="network_list.txt"
while read -r line
do
    name="$line"
    ping_stat=$(ping -c 4 $name 2>&1)
        if [ $? -ne 0 ]
        then 
            echo "server $name is down"
        else 
            echo "server $name is up and running"
        fi
done < "$filename"

But its output is unexpected and coming as "is up and running01" "is up and running02" .. network_list.txt file format is like

192.168.1.101
192.168.1.102
192.168.1.103
192.168.1.104
192.168.1.105

I just need to have a ping test on these serverss.

KTM
  • 213
  • 2
  • 6

0 Answers0