Ping Host Until it is up and email

view story

http://www.unix.com – Hi I am trying to write a script which runs until the host is up. i got it figured out that it needs to be in loop till it return $? = 0. Not getting it through though. I am not sure about the 6th line !!! Code: #!/bin/sh HOSTS="host.txt" ping(){ for myhost in "$HOSTS" do ping -c -1 "$myhost" && $? -eq 0 done exit } if ping $HOSTS then echo "server up" |mail -s "server up" [email protected] echo "server up" fi (HowTos)