Operating System - HP-UX
1831477 Members
3503 Online
110025 Solutions
New Discussion

Re: scripting question again

 
navin
Super Advisor

scripting question again

Hello All,
I have this script in place in init.d and set that as start at boot. For some reason when this script is started as the sws user from the location(SWSBIN) it starts in 5 to 10 min.But during system startup it won't, it takes more time and starts once we issue control sequenses as ctrlc or d.
What would be the problem.Please advice

#!/bin/sh

if [ $# -ne 1 ]; then
echo "Usage: $0 {start|stop|restart}"
exit 1
fi

SWSBIN=/export/host/application/sws/sws2007/bin


case "$1" in
'start')
echo "Starting swsis"
/bin/su - sws -c "$SWSBIN/swsis start"
;;
'stop')
echo "Stopping swsis"
/bin/su - sws -c "$SWSBIN/swsis stop"
;;
esac
#
Learning ...
2 REPLIES 2
Sandman!
Honored Contributor

Re: scripting question again

Is it on an NFS mount? May explain why it takes longer or doesn't run at startup.
A. Clay Stephenson
Acclaimed Contributor

Re: scripting question again

It's almost ceratinly the use of "su - sws ..." as opposed to "su sws ...". I know you want that "-" so that the user's .profile will be sourced and environment variables will be set BUT it's the .profile that is killing you. By default, .profile contains commands line tset, tabs, tput, and stty which expect stdin to be a TTY device (a terminal) --- which you ain't under rc.

You have two approaches:

1) In sws's .profile surrond those commands with:
if [[ -t 0 ]]
then
tset ...
stty
tabs
fi

which will only execute those commands when stdin is a terminal.

2) Create a small file that sets and exports your variable and let both your rc'ed script and sws's .profile source the file using the "." operator.

I actually like the second approach because it works from cron'ed scripts, .profile's, and rc'ed tasks.
If it ain't broke, I can fix that.