<?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: Background process in a while-read loop in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857781#M683673</link>
    <description>Try to add some stdin redirection for start_program... maybe it's 'stealing' data from stdin.&lt;BR /&gt; &lt;BR /&gt;grep pattern configfile | while read prc&lt;BR /&gt;do&lt;BR /&gt;start_program $prc  /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt;Best regards...&lt;BR /&gt;Dietmar.&lt;BR /&gt;</description>
    <pubDate>Tue, 17 Aug 2004 06:28:28 GMT</pubDate>
    <dc:creator>Dietmar Konermann</dc:creator>
    <dc:date>2004-08-17T06:28:28Z</dc:date>
    <item>
      <title>Background process in a while-read loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857773#M683665</link>
      <description>I am trying to start some background processes in a "while read ... do ... done" loop.&lt;BR /&gt;I have a configuration file that is parsed:&lt;BR /&gt;&lt;BR /&gt;grep pattern configfile | while read prc&lt;BR /&gt;do&lt;BR /&gt;   start_program $prc &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;This does not work anymore</description>
      <pubDate>Tue, 17 Aug 2004 01:47:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857773#M683665</guid>
      <dc:creator>Stig Eriksson</dc:creator>
      <dc:date>2004-08-17T01:47:34Z</dc:date>
    </item>
    <item>
      <title>Re: Background process in a while-read loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857774#M683666</link>
      <description>Shuld work fine. what shell you are in? &lt;BR /&gt;try redirecting your standard error and standard output to a log file instead of /dev/null. It should give some details there.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Aug 2004 02:12:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857774#M683666</guid>
      <dc:creator>monasingh_1</dc:creator>
      <dc:date>2004-08-17T02:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Background process in a while-read loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857775#M683667</link>
      <description>HI,&lt;BR /&gt;I think that your problem is that the file is parsed only once.&lt;BR /&gt;&lt;BR /&gt;TO have it work, try this:&lt;BR /&gt;&lt;BR /&gt;tail -f configfile| grep pattern | while read prc&lt;BR /&gt;do&lt;BR /&gt;start_program $prc &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;THis works IF you are just adding lines to your files, for example with a&lt;BR /&gt;echo "prog" &amp;gt;&amp;gt; configfile.&lt;BR /&gt;&lt;BR /&gt;But if you want to run a program, each time you modify a line i  that file, it's more difficult.&lt;BR /&gt;&lt;BR /&gt;You have to write a deamon that check the file ans parse it.&lt;BR /&gt;&lt;BR /&gt;Is this that you want ?&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;  Massimo&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Aug 2004 03:22:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857775#M683667</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2004-08-17T03:22:09Z</dc:date>
    </item>
    <item>
      <title>Re: Background process in a while-read loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857776#M683668</link>
      <description>You might also try redirecting stdin on the start-program from /dev/null.  This will stop it from trying to read from stdin, i.e.&lt;BR /&gt;&lt;BR /&gt;grep pattern configfile | while read prc&lt;BR /&gt;do&lt;BR /&gt;start_program $prc &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;lt; /dev/null &amp;amp;&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Although admittadly, a backgrounded process shouldn't be able to read from stdin as far as I'm aware..</description>
      <pubDate>Tue, 17 Aug 2004 03:22:34 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857776#M683668</guid>
      <dc:creator>Stuart Browne</dc:creator>
      <dc:date>2004-08-17T03:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: Background process in a while-read loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857777#M683669</link>
      <description>Your logic on shell is correct.&lt;BR /&gt;&lt;BR /&gt;set -x&lt;BR /&gt; grep pattern configfile | while read prc&lt;BR /&gt;do&lt;BR /&gt; start_program $prc &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&lt;BR /&gt; pid=$!&lt;BR /&gt; echo "Process ID: $pid"&lt;BR /&gt; ps -ef | grep -v grep | grep -w $pid&lt;BR /&gt;done &lt;BR /&gt;&lt;BR /&gt; It will give the behaviour / problem to you more.</description>
      <pubDate>Tue, 17 Aug 2004 03:27:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857777#M683669</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-08-17T03:27:59Z</dc:date>
    </item>
    <item>
      <title>Re: Background process in a while-read loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857778#M683670</link>
      <description>I will give some more info:&lt;BR /&gt;&lt;BR /&gt;This has been working before, but now, with another revision of ksh (82.10.2.61) it does not work anymore.&lt;BR /&gt;&lt;BR /&gt;The script works, so that a couple of processes are started, but the script does not terminate. It does not reach the line following the "done" command.&lt;BR /&gt;&lt;BR /&gt;A "nohup start_program ..." does not work either.</description>
      <pubDate>Tue, 17 Aug 2004 05:32:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857778#M683670</guid>
      <dc:creator>Stig Eriksson</dc:creator>
      <dc:date>2004-08-17T05:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: Background process in a while-read loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857779#M683671</link>
      <description>Have you tried enclosing the while loop in braces? I always do this when reading from a file or pipe...&lt;BR /&gt;&lt;BR /&gt;grep pattern configfile | {&lt;BR /&gt;while read prc&lt;BR /&gt;do&lt;BR /&gt;start_program $prc &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&lt;BR /&gt;done&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Aug 2004 05:43:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857779#M683671</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2004-08-17T05:43:09Z</dc:date>
    </item>
    <item>
      <title>Re: Background process in a while-read loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857780#M683672</link>
      <description>The problem may be on start_program function. &lt;BR /&gt;It is good to use exit 0 statement on processed function and main program.&lt;BR /&gt;&lt;BR /&gt;exit 0 statement is needed on your shell functions and main program.&lt;BR /&gt;&lt;BR /&gt;And more it's good to have your script and debug input to try on your problem. &lt;BR /&gt;&lt;BR /&gt; Use set -x to start the script and do as,&lt;BR /&gt;&lt;BR /&gt; start_program $prc &amp;gt; /tmp/testlog.log 2&amp;gt;&amp;amp;1&lt;BR /&gt;&lt;BR /&gt; so that start_program informations will be there in /tmp/testlog.log to track the problem&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Aug 2004 06:04:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857780#M683672</guid>
      <dc:creator>Muthukumar_5</dc:creator>
      <dc:date>2004-08-17T06:04:18Z</dc:date>
    </item>
    <item>
      <title>Re: Background process in a while-read loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857781#M683673</link>
      <description>Try to add some stdin redirection for start_program... maybe it's 'stealing' data from stdin.&lt;BR /&gt; &lt;BR /&gt;grep pattern configfile | while read prc&lt;BR /&gt;do&lt;BR /&gt;start_program $prc  /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;&lt;BR /&gt;done&lt;BR /&gt; &lt;BR /&gt;Best regards...&lt;BR /&gt;Dietmar.&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Aug 2004 06:28:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857781#M683673</guid>
      <dc:creator>Dietmar Konermann</dc:creator>
      <dc:date>2004-08-17T06:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: Background process in a while-read loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857782#M683674</link>
      <description>Hi,&lt;BR /&gt;if it never reach the "done", what is the content of the config file ?&lt;BR /&gt;&lt;BR /&gt;Maybe there is some garbage..&lt;BR /&gt;&lt;BR /&gt;Also, check the canghelog for the ksh. Since you mentioned a change in it, maybe there is a different behaviour then expected.&lt;BR /&gt;&lt;BR /&gt;HTH,&lt;BR /&gt;  Massimo</description>
      <pubDate>Tue, 17 Aug 2004 06:46:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857782#M683674</guid>
      <dc:creator>Massimo Bianchi</dc:creator>
      <dc:date>2004-08-17T06:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: Background process in a while-read loop</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857783#M683675</link>
      <description>Actually i don't remember how this was resolved. Just wanted to close this thread and assign points to those who tried to help me. Thanks to you all...</description>
      <pubDate>Fri, 16 Jan 2009 09:04:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/background-process-in-a-while-read-loop/m-p/4857783#M683675</guid>
      <dc:creator>Stig Eriksson</dc:creator>
      <dc:date>2009-01-16T09:04:27Z</dc:date>
    </item>
  </channel>
</rss>

