#!/bin/zsh
hosts=(gauss neumann emo wu)
user=webermi
if [ -z "$@" ] ; then
	echo "Usage: $(basename $0) all|hostname [hostname ...]"
	echo "with all=$hosts"
	exit -1
fi
[ "$@" != "all" ] && hosts=($@)

read -s "pass?Enter password for $user: "
echo
for host in $hosts ; do
    response=$(wget -q -O - \
         --http-user=$user --http-password="$pass" \
        "https://gaf.fs.lmu.de/ping/pong?wake=$host" )
    ret=$?
    if [ "$ret" -ne 0 ] ; then
        exit $ret
    fi
    echo $response | grep wakeonlan | sed -e 's:<br>::'
done
