I have two systems and I need to exectute a script on one from the other (ultimately from another script). The problem I have is that the script on the remote machine is in /sbin/init.d and I cant change it and the script runs a command in the background. When I issue the command "rsh <host> /sbin/init.d/appstart start" the command hangs, but the process is started on the remote system. However the rsh does not finish due to the & in the start script which is not what I want.
The command in the /sbin/init.d/appstart script needs to have the & otherwise it would hang when it was booting that system.
Anyone any suggestions on how I can run the script on the remote system and yet get the rsh command on the local system to return?
The script looks like:
I love deadlines. I like the whooshing sound they make as they fly by - Douglas Adams
The command in the /sbin/init.d/appstart script needs to have the & otherwise it would hang when it was booting that system.
Anyone any suggestions on how I can run the script on the remote system and yet get the rsh command on the local system to return?
The script looks like:
Code:
#!/sbin/sh
#####################################################################
# Variables
#####################################################################
# config path
CONFIG_PATH=<config file path>
export CONFIG_PATH
# Path to shared libraries
LD_LIBRARY_PATH=<shared lib path>
export LD_LIBRARY_PATH
#####################################################################
# Code
#####################################################################
case "$1" in
'start')
echo "Starting <APP>..."
if /usr/bin/app&; then
echo "APP started"
else
echo "Cannot start APP"
fi
;;
'stop')
echo "Stopping APP..."
while :
do
PID=`ps -eo pid,cmd | grep /usr/bin/app | grep -v grep | awk '{print $1}'`
if [ -n "$PID" ]
then
kill -TERM $PID
else
exit 0
fi
sleep 1
done
;;
*)
echo "usage: $0 {start|stop}"
;;
esac
I love deadlines. I like the whooshing sound they make as they fly by - Douglas Adams