<?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: korn shell issues in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099027#M146533</link>
    <description>can you provide a small sample of what your trying to do&lt;BR /&gt;&lt;BR /&gt;try doing this&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;print "1this shells pid is $$"&lt;BR /&gt;( print "this shells pid is $$;sleep 5) &amp;amp;&lt;BR /&gt;print "the background process pid is $!"&lt;BR /&gt;sleep 6&lt;BR /&gt;print "the background process pid is $!"&lt;BR /&gt;print "2this shells pid is $$"&lt;BR /&gt;&lt;BR /&gt;maybe this will help</description>
    <pubDate>Tue, 21 Oct 2003 18:51:42 GMT</pubDate>
    <dc:creator>curt larson_1</dc:creator>
    <dc:date>2003-10-21T18:51:42Z</dc:date>
    <item>
      <title>korn shell issues</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099025#M146531</link>
      <description>I asked earlier how to get a process id from a script that is run, automaticaly via Maestro.&lt;BR /&gt;&lt;BR /&gt;I have found that Korn shell sets a variable $! equal to the PID of the last background process run, I am doing a process that comes back after it is entered and runs for several hours, but it will not set the PID with $!, can anybody help?&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Tue, 21 Oct 2003 18:16:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099025#M146531</guid>
      <dc:creator>Fred Myers_1</dc:creator>
      <dc:date>2003-10-21T18:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: korn shell issues</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099026#M146532</link>
      <description>What about $$?  Returns the last PID.&lt;BR /&gt; &lt;BR /&gt;# echo $$</description>
      <pubDate>Tue, 21 Oct 2003 18:34:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099026#M146532</guid>
      <dc:creator>Michael Steele_2</dc:creator>
      <dc:date>2003-10-21T18:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: korn shell issues</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099027#M146533</link>
      <description>can you provide a small sample of what your trying to do&lt;BR /&gt;&lt;BR /&gt;try doing this&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;print "1this shells pid is $$"&lt;BR /&gt;( print "this shells pid is $$;sleep 5) &amp;amp;&lt;BR /&gt;print "the background process pid is $!"&lt;BR /&gt;sleep 6&lt;BR /&gt;print "the background process pid is $!"&lt;BR /&gt;print "2this shells pid is $$"&lt;BR /&gt;&lt;BR /&gt;maybe this will help</description>
      <pubDate>Tue, 21 Oct 2003 18:51:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099027#M146533</guid>
      <dc:creator>curt larson_1</dc:creator>
      <dc:date>2003-10-21T18:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: korn shell issues</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099028#M146534</link>
      <description>A common technique I use for storing data unique to the PID is.&lt;BR /&gt;&lt;BR /&gt;tfile=/tmp/process$$.dat&lt;BR /&gt;&lt;BR /&gt;# process stores data in the file Does work.&lt;BR /&gt;&lt;BR /&gt;rm $tfile&lt;BR /&gt;exit 0;&lt;BR /&gt;&lt;BR /&gt;SEP</description>
      <pubDate>Tue, 21 Oct 2003 19:48:00 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099028#M146534</guid>
      <dc:creator>Steven E. Protter</dc:creator>
      <dc:date>2003-10-21T19:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: korn shell issues</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099029#M146535</link>
      <description>Works for me:&lt;BR /&gt;&lt;BR /&gt;# sleep 60 &amp;amp;&lt;BR /&gt;[1]     255&lt;BR /&gt;# echo $!&lt;BR /&gt;255&lt;BR /&gt;&lt;BR /&gt;Maybe there's some confusion. The $! variable is set when you have run a background command with "command &amp;amp;".&lt;BR /&gt;When you say your process "comes back after it is entered", maybe it is a daemon process, which behaves differently, by spawning a child process and terminating the original. This will not set $!.&lt;BR /&gt;&lt;BR /&gt;I think you were running the Progress DB, and if this is anything like Oracle then its processes do run as daemons.&lt;BR /&gt;&lt;BR /&gt;From another window, if you can find the pid of your "child" process, and run "ps -fpPID", then look in the PPID (parent) column. If PPID matches your shell then it is a true child; if PPID = 1 then it is a daemon.&lt;BR /&gt;&lt;BR /&gt;I can explain further but it gets a bit technical. In a nutshell, if you run a child process with "command &amp;amp;", you will see $!. If you don't, you won't. In the former case you can also use the "wait" command to wait for all children to finish, in the latter you can't, because the daemon is not a true child.&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;BR /&gt;&lt;BR /&gt;--Grahan</description>
      <pubDate>Wed, 22 Oct 2003 02:17:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099029#M146535</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-10-22T02:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: korn shell issues</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099030#M146536</link>
      <description>&lt;BR /&gt;You can get the current PID with $$. I always use this variable to define uniqueness files.&lt;BR /&gt;&lt;BR /&gt;Ex:&lt;BR /&gt;&lt;BR /&gt;#! /bin/ksh&lt;BR /&gt;#&lt;BR /&gt;#&lt;BR /&gt;ls -la &amp;gt; file.$$&lt;BR /&gt;rm file.$$&lt;BR /&gt;&lt;BR /&gt;where:&lt;BR /&gt;&lt;BR /&gt;$$ -&amp;gt; PID of the Korn Shell that is interpreting the script.&lt;BR /&gt;&lt;BR /&gt;Tania</description>
      <pubDate>Wed, 22 Oct 2003 12:04:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099030#M146536</guid>
      <dc:creator>Tania Ap. Serpa Martins</dc:creator>
      <dc:date>2003-10-22T12:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: korn shell issues</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099031#M146537</link>
      <description>Grahm, thanks! yes I do belive it is running a demon process.  Is thier an easy way you know of to trap when this demon process completes?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;</description>
      <pubDate>Wed, 22 Oct 2003 12:50:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099031#M146537</guid>
      <dc:creator>Fred Myers_1</dc:creator>
      <dc:date>2003-10-22T12:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: korn shell issues</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099032#M146538</link>
      <description>I don't know of an easy way.&lt;BR /&gt;The "wait" command won't help here, this doesn't work for daemons.&lt;BR /&gt;I think the traditional way is to loop, running ps -fpPID, until the process exits, as I think you are already doing.&lt;BR /&gt;If anyone knows a better way I'd be interested to hear it.&lt;BR /&gt;-- Graham</description>
      <pubDate>Thu, 23 Oct 2003 02:11:37 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099032#M146538</guid>
      <dc:creator>Graham Cameron_1</dc:creator>
      <dc:date>2003-10-23T02:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: korn shell issues</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099033#M146539</link>
      <description>Hi Fred and Graham,&lt;BR /&gt;based on something I once saw mr. A. Clay Stephenson do....&lt;BR /&gt; &lt;BR /&gt;First, make a script that simulates something running for a period of time, e.g. ./runback.sh&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;sleep 20&lt;BR /&gt; &lt;BR /&gt;Then use the following as the controlling script:&lt;BR /&gt; &lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;BACK_JOB=./runback.sh&lt;BR /&gt;BACK_PID=""&lt;BR /&gt;RC=0&lt;BR /&gt;# start background job&lt;BR /&gt;$BACK_JOB &amp;amp;&lt;BR /&gt;BACK_PID=${!}&lt;BR /&gt;while [[ $RC = 0 ]]&lt;BR /&gt;do&lt;BR /&gt;        kill -s 0 ${BACK_PID} 2&amp;gt;/dev/null&lt;BR /&gt;        RC=$?&lt;BR /&gt;        sleep 5&lt;BR /&gt;        echo $BACK_PID is running&lt;BR /&gt;done&lt;BR /&gt;echo $BACK_PID has stopped   &lt;BR /&gt; &lt;BR /&gt;The controlling script tests for the existence of the background pid by issuing the kill -s 0 command; the moment it does not return zero it is considered stopped. &lt;BR /&gt;Perhaps an idea?&lt;BR /&gt;&lt;BR /&gt;regards,&lt;BR /&gt;John K.&lt;BR /&gt;</description>
      <pubDate>Thu, 23 Oct 2003 03:02:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/korn-shell-issues/m-p/3099033#M146539</guid>
      <dc:creator>john korterman</dc:creator>
      <dc:date>2003-10-23T03:02:36Z</dc:date>
    </item>
  </channel>
</rss>

