bash ping ip run command on reply

view story

http://stackoverflow.com – I would like to be able to check for ping replies to two different ip addresses and upon success execute a command. ie ping on response do ping on response execute command if doesn't respond it just does echo "waiting for response from" after it does it then goes onto echo "waiting for response from" when it does execute command. Any idea how I would convert the above into a bash script? (HowTos)