#!/bin/sh

# This is an example of using the aggregator execution source API to
# determine if a remote host is pingable or not.

# it extracts the hostname to ping from the supplied URL, which is 
# assumed to be in the format 
# http://myhost.globus.org:8080/wsrf/services/MyService

PINGTARGET=`echo $1 | sed 's%^http://\(.*\):.*$%\1%'`

if ping -c 3 -w 10 $PINGTARGET > /dev/null; then
    PINGRESULT="SUCCESS";
else
    echo PINGRESULT="FAIL";
fi

# 0 = success, 1 = not enough packets returned, 2 = other error


cat <<FIN
<?xml version="1.0" encoding="UTF-8"?>
<examplePingInformation">
$PINGRESULT
</examplePingInformation>
FIN

