Shell Programming Examples: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
===Ping all hosts in a subnet=== | ====Ping all hosts in a subnet==== | ||
subnet=”141.93.169 | subnet=”141.93.169 | ||
i=1 | i=1 | ||
while [ $i -lt 255 ] | while [ $i -lt 255 ] | ||
do | 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 | done | ||
Revision as of 10:05, 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