- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Need help with startup scripts that shouldnt be ru...
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
Forums
Discussions
Discussions
Discussions
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
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
01-17-2003 07:45 AM
01-17-2003 07:45 AM
su - patrol -c "/opt/patrol/PATROL3.3/PatrolAgent" > /tmp/patrol.startup
I am sure there is more than one way to approach this requirement, does anyone know the best way?
Thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2003 07:47 AM
01-17-2003 07:47 AM
Solutionmaybe PatrolAgent requires STDIN to be attached to a typewriter? Try to redirect /dev/console to STDIN:
su - patrol -c "/opt/patrol/PATROL3.3/PatrolAgent" > /tmp/patrol.startup < /dev/console
Regards,
Jochen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2003 07:48 AM
01-17-2003 07:48 AM
Re: Need help with startup scripts that shouldnt be run as root?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2003 07:54 AM
01-17-2003 07:54 AM
Re: Need help with startup scripts that shouldnt be run as root?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2003 07:57 AM
01-17-2003 07:57 AM
Re: Need help with startup scripts that shouldnt be run as root?
su - patrol -c .... as opposed to su patrol -c .... .
I know that you want to source patrol's .profile to set environment vars BUT that's your problem. There are almost certainly commands like tset and tabs which extect to be talking to a tty device (e.g. a terminal) which you now ain't.
The best way to do this is to create a file (e.g. /usr/local/bin/patrol_src.sh) that sets and exports these variables BUT does not contain an exit or return statement.
Now both patrol's .profile AND your rc script should source this same file via
. /usr/local/bin/patrol_src.sh
That way the vars are set in one place and you avoid the interactive command problems.
The other way to do this is use the "-" but surround all the interactive commands in .profile with
if [ -t 0 ]
then
stty ..
tset ..
fi
so that only in stdin is a tty device will the commands be executed.
I prefer the former method.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2003 07:58 AM
01-17-2003 07:58 AM
Re: Need help with startup scripts that shouldnt be run as root?
another issue might be placement of the "-signs. Try
su - patrol -c "/opt/patrol/PATROL3.3/PatrolAgent /dev/console >/tmp/patrol.startup 2>&1"
The 2>&1 redirects STDERR also ...
Regards,
Jochen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2003 08:02 AM
01-17-2003 08:02 AM
Re: Need help with startup scripts that shouldnt be run as root?
/sbin/init.d/patrol contains
PATH=/usr/sbin:/usr/bin:/sbin
export PATH
rval=0
set_return() {
x=$?
if [ $x -ne 0 ]; then
echo "EXIT CODE: $x"
rval=1 # script FAILed
fi
}
killproc() {
pid=`ps -e | awk '$NF~/'"$1"'/ {print $1}'`
if [ "X$pid" != "X" ]; then
if kill "$pid"; then
echo "$1 stopped"
else
rval=1
echo "Unable to stop $1"
fi
fi
}
case $1 in
'start_msg')
# Emit a _short_ message relating to running this script with
# the "start" argument; this message appears as part of the checklist.
echo "Starting Patrol"
;;
'stop_msg')
# Emit a _short_ message relating to running this script with
# the "stop" argument; this message appears as part of the checklist.
echo "Stopping Patrol"
;;
'start')
# source the system configuration variables
if [ -f /etc/rc.config ] ; then
. /etc/rc.config
else
echo "ERROR: /etc/rc.config defaults file MISSING"
fi
# Check to see if this script is allowed to run...
if [ "$START_PATROL" != 1 ]; then
rval=2
else
# Execute the commands to start your subsystem
/opt/patrol/3.2/startup_patrol.sh 2>&1
set_return
fi
;;
'stop')
# source the system configuration variables
if [ -f /etc/rc.config ] ; then
. /etc/rc.config
else
echo "ERROR: /etc/rc.config defaults file MISSING"
fi
# Check to see if this script is allowed to run...
if [ "$CONTROL_VARIABLE" != 1 ]; then
rval=2
else
# Execute the commands to stop your subsystem
echo "Ending Patrol"
fi
;;
*)
echo "usage: $0 {start|stop|start_msg|stop_msg}"
rval=1
;;
esac
exit $rval
The startup_patrol.sh script that is called contains
echo "Starting Patrol.."
cd /opt/patrol/3.2
echo "Starting Patrol" >> /tmp/patlog
date >> /tmp/patlog
nohup ./PatrolAgent >> /tmp/patlog 2>&1
Due to the config of the patrol installation on the boxes, the PatrolAgent process runs owned by the patrol ID.
On my installation, this is controlled by the scripts
~patrol/set_default_account.sh
~patrol/configure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2003 08:36 AM
01-17-2003 08:36 AM