#!/bin/bash # example03 # Manually edit this variable declaration to test it with this script IP1=192.168.9.90 # Use ping -c1 to send one packet only # Use > /dev/null 2>&1 to redirect standard out and # error to /dev/null because we don't need to see it ping -c1 $IP1 > /dev/null 2>&1 # Ping will return a zero if there was a packet returned # from the target IP if [ $? -eq 0 ];then echo "ping returned" else echo "no ping returned" fi # "> /dev/null" redirects standard out (stdout) to /dev/null # "which is where things go to dissappear on nix systems" # "2>&1" redirects standard error (stderr) to stdout so that # "they both go down the drain. In short there is no output # from ping with the exception of 0 or 1 to the system at exit. #end of script