<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Sleeper - Scripting help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/sleeper-scripting-help/m-p/3098093#M146341</link>
    <description>The problem is with some of the commands.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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:&lt;BR /&gt;if [ tty | grep -q '^/dev/' ]&lt;BR /&gt;then&lt;BR /&gt;    stty erase ^H&lt;BR /&gt;    stty dec&lt;BR /&gt;    ...&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Hope this solves your issues.&lt;BR /&gt;</description>
    <pubDate>Tue, 21 Oct 2003 04:03:27 GMT</pubDate>
    <dc:creator>Elmar P. Kolkman</dc:creator>
    <dc:date>2003-10-21T04:03:27Z</dc:date>
    <item>
      <title>Sleeper - Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sleeper-scripting-help/m-p/3098091#M146339</link>
      <description>I have just migrated an Application from DEC/ALPHA over to HP-UX, and have a bunch of scripts in a job scheduler (maestro) that run database (progress) sessions.  Their are jobs that need the previous progress sessions to finish so that I can mark the next one to start (dependancies).&lt;BR /&gt;&lt;BR /&gt;On the dec they used the following logic to accomplish this:&lt;BR /&gt;## Sleeper - MUST be present to maintain dependencies.&lt;BR /&gt;sleep 60&lt;BR /&gt;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&lt;BR /&gt;i=1&lt;BR /&gt;while [ -f /proc/${PID} ]    #Test to see whether loader is running.&lt;BR /&gt; do&lt;BR /&gt;        echo "Elapsed time:  ${i} min."&lt;BR /&gt;        sleep 60  #Snooze a bit longer if it is.&lt;BR /&gt;        i="$(expr ${i} + 1)"&lt;BR /&gt;        if [ ${i} -eq 180 ]&lt;BR /&gt;             exit 1;&lt;BR /&gt;        fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;I get the following error off of the ps command.&lt;BR /&gt;+ps -x&lt;BR /&gt;ps: don't know which terminal to select&lt;BR /&gt;&lt;BR /&gt;Also I am getting the following errors in the top of the script:&lt;BR /&gt;+ stty erase ^H kill ^U intr ^C eof ^D&lt;BR /&gt;stty: : Not a typewriter&lt;BR /&gt;+ stty hupcl ixon ixoff&lt;BR /&gt;stty: : Not a typewriter&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;So I re wrote the sleeper to look like this.&lt;BR /&gt;## Sleeper - MUST be present to maintain dependencies.&lt;BR /&gt;sleep 60&lt;BR /&gt;PID="$(ps -ex | grep ${USER} | awk '/\/exec\/.*po[s]/ {print $1}')"&lt;BR /&gt;i=1&lt;BR /&gt;while [ 0 -ne `ps -ef | grep ${PID} | grep -v grep | wc -l` ]    #Test to see wh&lt;BR /&gt;ether loader is running.&lt;BR /&gt; do&lt;BR /&gt;        echo "Elapsed time:  ${i} min."&lt;BR /&gt;        sleep 60  #Snooze a bit longer if it is.&lt;BR /&gt;        i="$(expr ${i} + 1)"&lt;BR /&gt;        if [ ${i} -eq 180 ]&lt;BR /&gt;         then&lt;BR /&gt;           exit 1&lt;BR /&gt;        fi&lt;BR /&gt;AND get the following ERROR's&lt;BR /&gt;+ ps -ef&lt;BR /&gt;+ grep&lt;BR /&gt;+ wc -l&lt;BR /&gt;+ grep -v grep&lt;BR /&gt;usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] -e pattern_list...&lt;BR /&gt;[-f pattern_file...] [file...]&lt;BR /&gt;usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] [-e pattern_list...]&lt;BR /&gt;-f pattern_file... [file...]&lt;BR /&gt;usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] pattern [file...]&lt;BR /&gt;&lt;BR /&gt;WICH LEADS to my 2 Questions.&lt;BR /&gt;&lt;BR /&gt;1.) is thier a better way to do this sleeper, or how do I fix this way.  Would a perl script maybe be better?&lt;BR /&gt;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.  &lt;BR /&gt;unknown mode: dec&lt;BR /&gt;&lt;BR /&gt;the .profile looks like this.&lt;BR /&gt;PATH=$HOME/bin:/usr/local/bin:/T008/titan/scripts:${PATH:-/usr/bin:.}&lt;BR /&gt;export PATH&lt;BR /&gt;if [ ! "$DT" ]; then&lt;BR /&gt;        stty dec&lt;BR /&gt;        tset -I -Q&lt;BR /&gt;fi&lt;BR /&gt;#stty erase ^H&lt;BR /&gt;PS1="[`whoami`@`hostname`]$ " ; export PS1&lt;BR /&gt;#LOGICALS SETUP FOR REPORTING&lt;BR /&gt;. /usr/users/dba/scripts/logicals&lt;BR /&gt;EDITOR=vi;export EDITOR&lt;BR /&gt;ORCDB=/db/t008att/attoholder&lt;BR /&gt;export ORCDB&lt;BR /&gt;PROTERMCAP=/T008/titan/scripts/awstermcap&lt;BR /&gt;alias l="ls -lrt"&lt;BR /&gt;TERM=vt320;export TERM&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;Fred</description>
      <pubDate>Tue, 21 Oct 2003 03:48:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sleeper-scripting-help/m-p/3098091#M146339</guid>
      <dc:creator>Fred Myers_1</dc:creator>
      <dc:date>2003-10-21T03:48:10Z</dc:date>
    </item>
    <item>
      <title>Re: Sleeper - Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sleeper-scripting-help/m-p/3098092#M146340</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I didn't invest on the grep error, but you could test the process rather using :&lt;BR /&gt;&lt;BR /&gt;while ps -p $PID &amp;gt;&amp;amp;- 2&amp;gt;&amp;amp;-&lt;BR /&gt;do&lt;BR /&gt;  ...&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards</description>
      <pubDate>Tue, 21 Oct 2003 04:03:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sleeper-scripting-help/m-p/3098092#M146340</guid>
      <dc:creator>Jean-Louis Phelix</dc:creator>
      <dc:date>2003-10-21T04:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: Sleeper - Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sleeper-scripting-help/m-p/3098093#M146341</link>
      <description>The problem is with some of the commands.&lt;BR /&gt;&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;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:&lt;BR /&gt;if [ tty | grep -q '^/dev/' ]&lt;BR /&gt;then&lt;BR /&gt;    stty erase ^H&lt;BR /&gt;    stty dec&lt;BR /&gt;    ...&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Hope this solves your issues.&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Oct 2003 04:03:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sleeper-scripting-help/m-p/3098093#M146341</guid>
      <dc:creator>Elmar P. Kolkman</dc:creator>
      <dc:date>2003-10-21T04:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Sleeper - Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sleeper-scripting-help/m-p/3098094#M146342</link>
      <description>I suggest to change&lt;BR /&gt;&lt;BR /&gt;while [ 0 -ne `ps -ef | grep ${PID} | grep -v grep | wc -l` ]&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;for the following&lt;BR /&gt;&lt;BR /&gt;while ( UNIX95= ps -e -o pid= | grep -q "${PID}"a )&lt;BR /&gt;do&lt;BR /&gt;&lt;BR /&gt;This new command line reports 0 if PID is found or 1 if not.&lt;BR /&gt;&lt;BR /&gt;UNIX95= ps -e -o pid=&lt;BR /&gt;prints ONLY all existing PID.&lt;BR /&gt;&lt;BR /&gt;grep -q "${PID}"&lt;BR /&gt;catches only that PID&lt;BR /&gt;&lt;BR /&gt;The error messages:&lt;BR /&gt;  stty: : Not a typewriter&lt;BR /&gt;are due to running the script without associated terminal (cron job or nohup job).&lt;BR /&gt;&lt;BR /&gt;I don't know what 'x' means as option of 'ps' command.</description>
      <pubDate>Tue, 21 Oct 2003 04:11:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sleeper-scripting-help/m-p/3098094#M146342</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2003-10-21T04:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: Sleeper - Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sleeper-scripting-help/m-p/3098095#M146343</link>
      <description>I a PID is given, the shortest ways to check if  it is alive are:&lt;BR /&gt;&lt;BR /&gt;a) using 'ps -p PID' as Jean-Louise wrote.&lt;BR /&gt;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.&lt;BR /&gt;&lt;BR /&gt;I hope this lines be useful.</description>
      <pubDate>Tue, 21 Oct 2003 04:21:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sleeper-scripting-help/m-p/3098095#M146343</guid>
      <dc:creator>Jdamian</dc:creator>
      <dc:date>2003-10-21T04:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Sleeper - Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sleeper-scripting-help/m-p/3098096#M146344</link>
      <description>Problem 1&lt;BR /&gt;"ps -ex" apparently behaves different on alpha. &lt;BR /&gt;For hp-ux, change "ps -ex | grep ${USER}" to "ps -fu${USER}" in your first ps line. &lt;BR /&gt;Note that if this line returns &amp;gt; 1 PID then the next section fails.&lt;BR /&gt;Your while loop seems to be missing the closing "done". &lt;BR /&gt;Assuming this is a typo, then I would also suggest changing your while line (all of it) to:&lt;BR /&gt;"while { ps -fp$PID &amp;gt;/dev/null 2&amp;gt;&amp;amp;1 ;}"&lt;BR /&gt;--&lt;BR /&gt;Problem 2 &lt;BR /&gt;In .profile, change&lt;BR /&gt;--&lt;BR /&gt;if [ ! "$DT" ]; then&lt;BR /&gt;stty dec&lt;BR /&gt;tset -I -Q&lt;BR /&gt;fi&lt;BR /&gt;-- to --&lt;BR /&gt;if [ -t ];then ## Tests for interactive terminal&lt;BR /&gt;eval $(ttytype -s) ## set up tty type&lt;BR /&gt;fi&lt;BR /&gt;--&lt;BR /&gt;man ttytype for more info&lt;BR /&gt;-- Graham</description>
      <pubDate>Tue, 21 Oct 2003 04:47:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sleeper-scripting-help/m-p/3098096#M146344</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-10-21T04:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: Sleeper - Scripting help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/sleeper-scripting-help/m-p/3098097#M146345</link>
      <description>the -x does exist on HP 11.i  It allows the whole line to appear, ie doens't truncate the command.  I need to save this part because the command's path is so long, the end gets trunced off.&lt;BR /&gt;&lt;BR /&gt;Thanks for the help!!!&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 21 Oct 2003 11:14:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/sleeper-scripting-help/m-p/3098097#M146345</guid>
      <dc:creator>Fred Myers_1</dc:creator>
      <dc:date>2003-10-21T11:14:32Z</dc:date>
    </item>
  </channel>
</rss>

