Shell Programming Examples: Difference between revisions
Jump to navigation
Jump to search
(Created page with 'Ping all hosts in a subnet subnet=”141.93.169” i=1 while [ $i -lt 255 ] do ping ${subnet}.${i} 2 1>/dev/null 2>&1 if [ $? -ne 0 ] ; then echo "${subnet}.$…') |
No edit summary |
||
| Line 1: | Line 1: | ||
Ping all hosts in a subnet | ===Ping all hosts in a subnet=== | ||
subnet=”141.93. | subnet=”141.93.169 | ||
i=1 | i=1 | ||
while [ $i -lt 255 ] | while [ $i -lt 255 ] | ||
Revision as of 10:01, 22 September 2011
Ping all hosts in a subnet
subnet=”141.93.169 i=1 while [ $i -lt 255 ] do
ping ${subnet}.${i} 2 1>/dev/null 2>&1
if [ $? -ne 0 ] ; then
echo "${subnet}.${i},down"
else echo "${subnet}.${i},up"
fi
i=$(expr $i + 1 )
done