- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Sleeper - Scripting help
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
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
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
тАО10-20-2003 08:48 PM
тАО10-20-2003 08:48 PM
On the dec they used the following logic to accomplish this:
## Sleeper - MUST be present to maintain dependencies.
sleep 60
PID="$(ps x | awk '/\/exec\/.*po[s]/ {print $1}')" # I had to change this to a ps -x as HP needs the - for it to recognize this as a flag
i=1
while [ -f /proc/${PID} ] #Test to see whether loader is running.
do
echo "Elapsed time: ${i} min."
sleep 60 #Snooze a bit longer if it is.
i="$(expr ${i} + 1)"
if [ ${i} -eq 180 ]
exit 1;
fi
done
I get the following error off of the ps command.
+ps -x
ps: don't know which terminal to select
Also I am getting the following errors in the top of the script:
+ stty erase ^H kill ^U intr ^C eof ^D
stty: : Not a typewriter
+ stty hupcl ixon ixoff
stty: : Not a typewriter
So I re wrote the sleeper to look like this.
## Sleeper - MUST be present to maintain dependencies.
sleep 60
PID="$(ps -ex | grep ${USER} | awk '/\/exec\/.*po[s]/ {print $1}')"
i=1
while [ 0 -ne `ps -ef | grep ${PID} | grep -v grep | wc -l` ] #Test to see wh
ether loader is running.
do
echo "Elapsed time: ${i} min."
sleep 60 #Snooze a bit longer if it is.
i="$(expr ${i} + 1)"
if [ ${i} -eq 180 ]
then
exit 1
fi
AND get the following ERROR's
+ ps -ef
+ grep
+ wc -l
+ grep -v grep
usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] -e pattern_list...
[-f pattern_file...] [file...]
usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] [-e pattern_list...]
-f pattern_file... [file...]
usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] pattern [file...]
WICH LEADS to my 2 Questions.
1.) is thier a better way to do this sleeper, or how do I fix this way. Would a perl script maybe be better?
2.) What do I do about the stty settings, they seem to cause problems, I also see the following error message related to the terminal on login.
unknown mode: dec
the .profile looks like this.
PATH=$HOME/bin:/usr/local/bin:/T008/titan/scripts:${PATH:-/usr/bin:.}
export PATH
if [ ! "$DT" ]; then
stty dec
tset -I -Q
fi
#stty erase ^H
PS1="[`whoami`@`hostname`]$ " ; export PS1
#LOGICALS SETUP FOR REPORTING
. /usr/users/dba/scripts/logicals
EDITOR=vi;export EDITOR
ORCDB=/db/t008att/attoholder
export ORCDB
PROTERMCAP=/T008/titan/scripts/awstermcap
alias l="ls -lrt"
TERM=vt320;export TERM
Thanks
Fred
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2003 09:03 PM
тАО10-20-2003 09:03 PM
Re: Sleeper - Scripting help
I didn't invest on the grep error, but you could test the process rather using :
while ps -p $PID >&- 2>&-
do
...
done
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2003 09:03 PM
тАО10-20-2003 09:03 PM
Re: Sleeper - Scripting help
It seems you'd better do a ps -fu ${USER} and make sure ${USER} is set before doing that. Because it seems that that is causing the error message from grep. And the message from ps comes from the 'x' option that ps doesn't recognize on HP-UX.
For stty I would do something like look at the result from the tty command. If it doesn't result a string like '/dev/...', stty won't work. So in your .profile do:
if [ tty | grep -q '^/dev/' ]
then
stty erase ^H
stty dec
...
fi
Hope this solves your issues.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2003 09:11 PM
тАО10-20-2003 09:11 PM
Re: Sleeper - Scripting help
while [ 0 -ne `ps -ef | grep ${PID} | grep -v grep | wc -l` ]
do
for the following
while ( UNIX95= ps -e -o pid= | grep -q "${PID}"a )
do
This new command line reports 0 if PID is found or 1 if not.
UNIX95= ps -e -o pid=
prints ONLY all existing PID.
grep -q "${PID}"
catches only that PID
The error messages:
stty: : Not a typewriter
are due to running the script without associated terminal (cron job or nohup job).
I don't know what 'x' means as option of 'ps' command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2003 09:21 PM
тАО10-20-2003 09:21 PM
Re: Sleeper - Scripting help
a) using 'ps -p PID' as Jean-Louise wrote.
b) using '/usr/bin/kill -s NULL'. Note that I typed the whole path of kill command because internal command called 'kill' embeded in POSIX shell or Korn shell don't accept signal NULL.
I hope this lines be useful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2003 09:47 PM
тАО10-20-2003 09:47 PM
Solution"ps -ex" apparently behaves different on alpha.
For hp-ux, change "ps -ex | grep ${USER}" to "ps -fu${USER}" in your first ps line.
Note that if this line returns > 1 PID then the next section fails.
Your while loop seems to be missing the closing "done".
Assuming this is a typo, then I would also suggest changing your while line (all of it) to:
"while { ps -fp$PID >/dev/null 2>&1 ;}"
--
Problem 2
In .profile, change
--
if [ ! "$DT" ]; then
stty dec
tset -I -Q
fi
-- to --
if [ -t ];then ## Tests for interactive terminal
eval $(ttytype -s) ## set up tty type
fi
--
man ttytype for more info
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-21-2003 04:14 AM
тАО10-21-2003 04:14 AM
Re: Sleeper - Scripting help
Thanks for the help!!!