- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- script question
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2007 08:02 AM
тАО12-06-2007 08:02 AM
#!/bin/sh
if [ $# -ne 1 ]; then
echo "Usage: $0 {start|stop|restart}"
exit 1
fi
WBSBIN=/export/home/appl/abot/sw/wbs/wb07/bin:/export/home/appl/abot/sw/wbs/ws07/bin
case "$1" in
'start')
echo "Starting wbs"
sleep 8
/bin/su - wbs -c "$WBSBIN/wbs start"
;;
'stop')
echo "Stopping wbs"
/bin/su - wbs -c "$WBSBIN/wbs stop"
;;
esac
#
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2007 08:10 AM
тАО12-06-2007 08:10 AM
Re: script question
Yes... if its root executing the script otherwise it will ask for the passwd and so the only alternative would be to use sudo and give that user the root priviledge to execute this script...
All the best
Victor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2007 08:13 AM
тАО12-06-2007 08:13 AM
SolutionI know you want to use "su -" so that user wbs's .profile will be sourced and the environment is set. The problem is that on HP-UX, most .profile's have commands which are terminal-related and expect stdin to be a terminal --- which it isn't under rc.
There are two approaches that will work:
1) Edit .profile and surround commands like tset, tput, tabs with:
if [[ -t 0 ]]
then
tset ..
tput ..
fi
2) Don't use the "-" in the su command instead use "su wbc -c ...." and thus don't souce the .profile. I typically setup a special file (e.g. /usr/local/bin/wbsenv.sh) and let this file set and export any needed environment variables. I then let wbs's .profile and any rc'ed or cron'ed scripts source the file using the "." (dot) operator.
e.g.
. /usr/local/bin/wbsenv.sh
case "${1}" in
start)
This way, you change the environment variables in one place and all scripts work.
NOTE: Do not use an exit or return statement in the sourced file because this will exit the foreground process. The "." command does not spawn a child process but rather includes the file just as though it were part of the main script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2007 08:15 AM
тАО12-06-2007 08:15 AM
Re: script question
I don't know if you made a typo, but
$WBSBIN
will give you
/export/home/appl/abot/sw/wbs/wb07/bin:/export/home/appl/abot/sw/wbs/ws07/bin/wbs
I think this should be
WBSBIN=/export/home/appl/abot/sw/wbs/wb07/bin
Regards,
Robert-Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2007 08:15 AM
тАО12-06-2007 08:15 AM
Re: script question
if [[ $- = *i* ]]
then
#Inetracitve shell so set term etc...
stty erase "^H" kill "^U" intr "^C" eof "^D"
stty hupcl ixon ixoff opost
fi
All the best
Victor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2007 08:18 AM
тАО12-06-2007 08:18 AM
Re: script question
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2007 08:25 AM
тАО12-06-2007 08:25 AM
Re: script question
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-06-2007 08:31 AM
тАО12-06-2007 08:31 AM
Re: script question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-07-2007 12:13 AM
тАО12-07-2007 12:13 AM
Re: script question
#!/bin/sh
if [ $# -ne 1 ]; then
echo "Usage: $0 {start|stop|restart}"
exit 1
fi
WBSBIN=/export/home/appl/abot/sw/wbs/wb07/bin:/export/home/appl/abot/sw/wbs/ws07/bin
case "$1" in
'start')
echo "Starting wbs"
sleep 8
su - wbs <
"$WBSBIN/wbs start"
exit
END
;;
'stop')
echo "Stopping wbs"
su - wbs <
exit
END
;;
esac
#
You can easily see the format
su -
exit
END
With best regards
-NKG-