> lampiran script: > > #!/bin/bash > hosttoping=$1 > if [ -z "$1" ]; then > echo "usage: $myname hostname" > exit 1 > fi > ping -c3 $hosttoping > /dev/null 2>&1 > if test "$?" = "0" ; then > echo up > else > echo down > mestinya diakhiri dengan "fi"
implmentasi lain: #!/bin/bash hosttoping=$1 # untuk exit status dari script ini # 0 = success # 1 = destination error # 2 = parameter error status=0 if [ -z "$1" ]; then echo "usage: $0 hostname" exit 2 fi if ping -q -c3 $hosttoping > /dev/null; then echo up else echo down status=1 fi exit $status barangkali perlu memanfaatkan exit status dari "ping", quote dari man ping: If ping does not receive any reply packets at all it will exit with code 1. If a packet count and deadline are both specified, and fewer than count packets are received by the time the deadline has arrived, it will also exit with code 1. On other error it exits with code 2. Otherwise it exits with code 0. This makes it possible to use the exit code to see if a host is alive or not. salam -- Yudhi Kusnanto |- +62 811 292 184 STMIK Akakom Yogyakarta |- +62 274 486 438 Indonesia -- Berhenti langganan: [EMAIL PROTECTED] Arsip dan info: http://linux.or.id/milis.php