#!/bin/sh watchfile=/tmp/$(hostname).ip while true; do case $1 in -h|--help) echo "$0 [--watchfile=$watchfile] " exit 0 ;; --watchfile) watchfile=$2 shift ;; *) break ;; esac shift done server=$1 pubip=$(/usr/local/bin/printPublicIp) if ! echo "$pubip" | egrep -q "^([0-9]+\\.)+[0-9]+$" ; then echo "Wrong IP address format" exit 1 fi echo "Notify $server that $(hostname) has address ${pubip}." . $HOME/.profile-sshagent ssh $server "echo $pubip > /tmp/euklid.ip"