#!/bin/sh
#
# Program: RemoteRunSafely.sh
#
# Synopsis: This script simply runs another program remotely using ssh.
# It always returns the another program exit code or exit with
# code 255 which indicates that the program could not be executed.
#
# Syntax:
#
# RemoteRunSafely.sh <hostname> [-l <login_name>] [-p <port>]
# <program> <args...>
#
# where:
# <hostname> is the remote host to execute the program,
# <login_name> is the username on the remote host,
# <port> is the port used by the remote client,
# <program> is the path to the program to run,
# <args...> are the arguments to pass to the program.
#
# Save a copy of the original arguments in a string before we
# clobber them with the shift command.
ORIG_ARGS=""
#DEBUG: echo 'GOT: '$ORIG_ARGS
RHOST=
RUSER=
RCLIENT=ssh
RPORT=
WORKING_DIR=
if [; then
RUSER=
fi
if [; then
RPORT="-p "
fi
PROGRAM=
WORKING_DIR=
#DEBUG: echo 'DIR='${0%%`basename $0`}
#DEBUG: echo 'RHOST='$RHOST
#DEBUG: echo 'RUSER='$RUSER
#DEBUG: echo 'PROGRAM='$PROGRAM
#DEBUG: echo 'WORKING_DIR='$WORKING_DIR
#DEBUG: echo 'ARGS='$*
# Sanity check
if [; then
fi
# Local program file must exist and be execuatble
local_program="/"
if [; then
fi
connection='@'
remote="./"
(
| \
)
err=
#DEBUG: echo script exit $err