<?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: Shell script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809842#M84014</link>
    <description>:-) Thank you all for promptly responding. Some solutions were very creative! I will try your approach &amp;amp; let you know what happened. Everyone gets a 10 for being very helpful!</description>
    <pubDate>Thu, 19 Sep 2002 16:55:18 GMT</pubDate>
    <dc:creator>Sharvil Desai</dc:creator>
    <dc:date>2002-09-19T16:55:18Z</dc:date>
    <item>
      <title>Shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809833#M84005</link>
      <description>Hi,&lt;BR /&gt;What I have to do is,&lt;BR /&gt;write a shell-script that keeps on checking whether the file test.txt exists, and once it does exist then load that in the database.&lt;BR /&gt;I have accomplished that by doing,&lt;BR /&gt;&lt;BR /&gt;while ! test -s data.txt&lt;BR /&gt;do&lt;BR /&gt;   sleep 120&lt;BR /&gt;done&lt;BR /&gt;if test -s data.txt&lt;BR /&gt;then&lt;BR /&gt; #load the data in database&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;However, I also have to put in a condition in the while loop saying keep on checking for test.txt for three hours, but if it's not there in 3 hours then stop checking for that file and get out of the loop.&lt;BR /&gt;&lt;BR /&gt;Can someone please provide some feedback on how to accomplish this? Thank you.</description>
      <pubDate>Thu, 19 Sep 2002 15:15:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809833#M84005</guid>
      <dc:creator>Sharvil Desai</dc:creator>
      <dc:date>2002-09-19T15:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809834#M84006</link>
      <description>Sorry for the confusion,&lt;BR /&gt;Please read data.txt wherever I have said test.txt. The file I have to wait for is data.txt&lt;BR /&gt;Thank you.</description>
      <pubDate>Thu, 19 Sep 2002 15:17:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809834#M84006</guid>
      <dc:creator>Sharvil Desai</dc:creator>
      <dc:date>2002-09-19T15:17:23Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809835#M84007</link>
      <description>What if you created another script that launched your script that does a sleep for 3 hours, and when it wakes up it can kill the process if it hasn't processed the load.&lt;BR /&gt;&lt;BR /&gt;script1:&lt;BR /&gt;&lt;BR /&gt;while ! test -s data.txt &lt;BR /&gt;do &lt;BR /&gt;sleep 120 &lt;BR /&gt;done &lt;BR /&gt;if test -s data.txt &lt;BR /&gt;then &lt;BR /&gt;#load the data in database &lt;BR /&gt;mv data.txt loaddone.txt&lt;BR /&gt;fi &lt;BR /&gt;&lt;BR /&gt;script2:&lt;BR /&gt;&lt;BR /&gt;sh script1 &amp;amp;&lt;BR /&gt;myjob=$!&lt;BR /&gt;sleep 10800&lt;BR /&gt;if test -e loaddone.txt&lt;BR /&gt;then&lt;BR /&gt;kill -15 $myjob&lt;BR /&gt;else&lt;BR /&gt;rm loaddone.txt&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;HTH&lt;BR /&gt;&lt;BR /&gt;-- Rod Hills&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Sep 2002 15:29:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809835#M84007</guid>
      <dc:creator>Rodney Hills</dc:creator>
      <dc:date>2002-09-19T15:29:42Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809836#M84008</link>
      <description># i = loop counter&lt;BR /&gt;# l = max number of loops&lt;BR /&gt;# s = sleep seconds&lt;BR /&gt;typeset -i i=0 l=0 s=120&lt;BR /&gt;let l=3*3600/$s&lt;BR /&gt;while [ $i -lt $l -a ! -s data.txt ]&lt;BR /&gt;do&lt;BR /&gt;sleep $s&lt;BR /&gt;done&lt;BR /&gt;if [ -s data.txt ]&lt;BR /&gt;then&lt;BR /&gt;# load&lt;BR /&gt;fi</description>
      <pubDate>Thu, 19 Sep 2002 15:35:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809836#M84008</guid>
      <dc:creator>Jordan Bean</dc:creator>
      <dc:date>2002-09-19T15:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809837#M84009</link>
      <description>You could simply limit the number of times that you do the loop...&lt;BR /&gt;&lt;BR /&gt;let HOURS=3 #hours to run&lt;BR /&gt;let SLEEP=120 # seconds to check&lt;BR /&gt;let LOOPS="(HOURS*3600)/SLEEP"&lt;BR /&gt;&lt;BR /&gt;while (( LOOPS ));&lt;BR /&gt;do&lt;BR /&gt; let LOOPS=LOOPS-1&lt;BR /&gt; if [[ -s data.txt ]];&lt;BR /&gt; then &lt;PROCESS file=""&gt;&lt;BR /&gt; fi&lt;BR /&gt; sleep ${SLEEP}&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;John&lt;/PROCESS&gt;</description>
      <pubDate>Thu, 19 Sep 2002 15:37:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809837#M84009</guid>
      <dc:creator>John Palmer</dc:creator>
      <dc:date>2002-09-19T15:37:02Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809838#M84010</link>
      <description>Do this&lt;BR /&gt;&lt;BR /&gt;for TEST in /test.data&lt;BR /&gt;do&lt;BR /&gt;your arguments come here&lt;BR /&gt;if [ $TEST = 1 ]&lt;BR /&gt;then&lt;BR /&gt;exit&lt;BR /&gt;fi&lt;BR /&gt;done&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Anil</description>
      <pubDate>Thu, 19 Sep 2002 15:39:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809838#M84010</guid>
      <dc:creator>Anil C. Sedha</dc:creator>
      <dc:date>2002-09-19T15:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809839#M84011</link>
      <description>Forgot to add the sleep parameter there.&lt;BR /&gt;&lt;BR /&gt;put sleep 10800 after the step&lt;BR /&gt;&lt;BR /&gt;your arguments come here&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Anil</description>
      <pubDate>Thu, 19 Sep 2002 15:39:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809839#M84011</guid>
      <dc:creator>Anil C. Sedha</dc:creator>
      <dc:date>2002-09-19T15:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809840#M84012</link>
      <description>&lt;BR /&gt;another way:&lt;BR /&gt;&lt;BR /&gt;sleep 10800 &amp;amp; # start sleeper&lt;BR /&gt;while kill -0 %1 &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;BR /&gt;do&lt;BR /&gt;   [ -s data.txt ] &amp;amp;&amp;amp; break&lt;BR /&gt;   sleep 120&lt;BR /&gt;done&lt;BR /&gt;kill -HUP %1 # stop sleeper&lt;BR /&gt;if [ -s data.txt ]&lt;BR /&gt;then&lt;BR /&gt;# load&lt;BR /&gt;fi</description>
      <pubDate>Thu, 19 Sep 2002 15:49:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809840#M84012</guid>
      <dc:creator>Jordan Bean</dc:creator>
      <dc:date>2002-09-19T15:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809841#M84013</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;It probably won't happen often but depending on the size of data.txt, your script could try to load the database while the file is still being written.&lt;BR /&gt;&lt;BR /&gt;You may want to add a check using fuser or lsof to verify the file isn't being accessed before you do your load.&lt;BR /&gt;&lt;BR /&gt;An fuser example:&lt;BR /&gt;inuse=`fuser $file 2&amp;gt;&amp;amp;1 | awk '{print $2}'`&lt;BR /&gt;if [ -z "${inuse}" ]&lt;BR /&gt;then&lt;BR /&gt;echo File ${file} not in use&lt;BR /&gt;# load the database&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Darrell</description>
      <pubDate>Thu, 19 Sep 2002 16:49:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809841#M84013</guid>
      <dc:creator>Darrell Allen</dc:creator>
      <dc:date>2002-09-19T16:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809842#M84014</link>
      <description>:-) Thank you all for promptly responding. Some solutions were very creative! I will try your approach &amp;amp; let you know what happened. Everyone gets a 10 for being very helpful!</description>
      <pubDate>Thu, 19 Sep 2002 16:55:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809842#M84014</guid>
      <dc:creator>Sharvil Desai</dc:creator>
      <dc:date>2002-09-19T16:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Shell script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809843#M84015</link>
      <description>Hi guys,&lt;BR /&gt;Again thank you for your feedback. To me Jordan's first answer was the most straightforward. The logic was easy to follow, so I have decided to use that...but everyone's got their points :-) !</description>
      <pubDate>Thu, 19 Sep 2002 20:45:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shell-script/m-p/2809843#M84015</guid>
      <dc:creator>Sharvil Desai</dc:creator>
      <dc:date>2002-09-19T20:45:26Z</dc:date>
    </item>
  </channel>
</rss>

