declare displayhost=${DISPLAY%:*} declare pingcmd case $OSTYPE in solaris*) pingcmd="ping $displayhost 1";; linux*) pingcmd="ping -c 1 $displayhost";; *) : ;; # TODO insert other flavors of ping here esac # If displayhost is blank DISPLAY is probably ":0" so we # shouldn't ping [[ -z "$displayhost" ]] && pingcmd="" if ! ( $pingcmd && xdpyinfo ) >/dev/null 2>&1; then # Either we can't ping the machine or xdpyinfo failed. # Either way, X is probably not going to work! unset _running_X fi