#!/bin/bash

if [[ "$#" -lt "2" ]]; then
	echo "Usage: $0 <[username@]hostname_or_fqdn> <command> [other_ssh_args]" >&2
	exit 3
fi

eval "$(<~/.ssh/.ssh-agent)" >/dev/null

where="$1"
shift
command="$1"
shift

#echo 'exec /usr/bin/ssh -T ##'"$where"'## ##'"$command"'## ##'"$*##" >> /usr/local/monitoring/log/punotify.log
#exec /usr/bin/ssh -T $where "$command" $* 2>>/usr/local/monitoring/log/punotify.log
exec /usr/bin/ssh -T $where "$command" $* 2>&1

exit $?

