Skip to content

Commit a4cb197

Browse files
author
Ankam Ravi Kumar
authored
Create for-loop.sh
1 parent 06fb1ef commit a4cb197

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

for-loop.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
#Purpose: For loop example
3+
#Version:1.0
4+
#website: https://arkit.co.in
5+
#Created Date: Wed May 16 19:26:02 IST 2018
6+
#Modified Date:
7+
#Author: Ankam Ravi Kumar
8+
# START #
9+
for i in `cat hostfile`
10+
do
11+
ping -c 1 $i > /tmp/pingresults
12+
valid=`echo $?`
13+
if [ $valid -gt 1 ]; then
14+
echo "$i Host is not reachable"
15+
else
16+
echo "$i Host is Up"
17+
fi
18+
done
19+
# END #

0 commit comments

Comments
 (0)