#!/bin/sh
#
#
# COPYRIGHT:    Licensed material - Property of IBM
#               5765-530 (C) Copyright IBM Corp. 1995,1996
#               All Rights Reserved
#               US Government Users Restricted Rights -
#               Use, duplication or disclosure restricted
#               by GSA ADP Schedule Contract with IBM Corp.
#
#
#########################################################################
#
# wrapper for commands to be executed by DataHub/Unix
#
# used by WD Server and watchdogs to execute os commands
# 
# added logic to log action to application syslog. 
# default local syslog will be local3. This can be changed by updating this file
# and the retrieve script file
# The logger command is expect to be in /usr/bin for HP and AIX and
#     in /usr/ucb for Solaris (These are standard system libraries)
# For Solaris, the installation procedure adds the following soft link:
# ln -s /usr/ucb/logger /usr/bin/logger

case $# in
1 )	chmod a+x $1
	$1
	;;
3 )	chmod a+x $3
        /usr/bin/logger -p local3.info [dh] Rule: $1 started by $2: `cat $3`
        /bin/su - $2 -c $3
        error=$?
        /usr/bin/logger -p local3.info [dh] Rule: $1 command ended: `cat $3` "(RC=$error)"
        /bin/rm $3
	;;
* )
	/bin/echo "Usage: `basename $0` [rulenum] [userid] filename" 1>&2
	exit 1
	;;
esac
