[bash]#!/bin/sh
HOST="silveiraneto.net"
if ping -c 1 $HOST > /dev/null
then
echo your command
fi
[/bash]
- replace silveiraneto.net for your desired hostname or ip
- ping sends only one package (-c 1) and ignores the text output
- a ping is successful returns 0 and the if proceeds
- replace the echo line with your command