<?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: Need assistance with script... in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795414#M641397</link>
    <description>&lt;!--!*#--&gt;&amp;gt;Ignore the last one.&lt;BR /&gt;&lt;BR /&gt;As MK mentioned please fix your indentation.  This helps you and us understand your script better.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;while [ `date +%H%M` -le 2359 -o `date +%H%M` -ge 0100 ]; do&lt;BR /&gt;&lt;BR /&gt;This range check isn't useful.  Why not replace it by: :-)&lt;BR /&gt;while true; do&lt;BR /&gt;&lt;BR /&gt;You probably want:&lt;BR /&gt;while (( $(date +%H%M) &amp;gt;= 0100 &amp;amp;&amp;amp; $(date +%H%M) &amp;lt;= 2359 )); do&lt;BR /&gt;&lt;BR /&gt;Note: The AND.  And I usually put the lower bound first.&lt;BR /&gt;Your other range check seems fine.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;# Pre-delete Files&lt;BR /&gt;&amp;gt;if [ -f ${old_listfile} ]&lt;BR /&gt;&lt;BR /&gt;Why work so hard?&lt;BR /&gt;rm -f ${old_listfile}&lt;BR /&gt;if [ $? -ne 0 ]; then&lt;BR /&gt;   echo "Delete of ${old_listfile} failed"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Add mv -f here:&lt;BR /&gt;mv ${latest_listfile} ${old_listfile}&lt;BR /&gt;&lt;BR /&gt;&amp;gt;grep "${jobset} ${job} ${jno} ${qual}" $old_listfile &amp;gt;&amp;gt;/dev/null&lt;BR /&gt;&lt;BR /&gt;Better to use grep -q:&lt;BR /&gt;grep -q "${jobset} ${job} ${jno} ${qual}" $old_listfile&lt;BR /&gt;&lt;BR /&gt;And can remove the evil cat from:&lt;BR /&gt;cat $latest_listfile | while read jobset job jno qual;  do&lt;BR /&gt;&lt;BR /&gt;while read jobset job jno qual; do&lt;BR /&gt;...&lt;BR /&gt;done &amp;lt; $latest_listfile</description>
    <pubDate>Sat, 04 Jun 2011 16:39:32 GMT</pubDate>
    <dc:creator>Dennis Handly</dc:creator>
    <dc:date>2011-06-04T16:39:32Z</dc:date>
    <item>
      <title>Need assistance with script...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795408#M641391</link>
      <description>Hi,&lt;BR /&gt;I created a script on Linux server. We work on a JOb scheduling tool which is TNG (very old software) just like maestro...Now I have made script to run around autoscan..autoscan in TNG means New day load (Like Jnext day in Maestro)...&lt;BR /&gt;Script work is to :&lt;BR /&gt;Checks on the TNG Tracking Database for jobs stuck in WRSRC(Waiting for resource) status. Job will start straight after Autoscan(1 AM) and run a 24-hour cyclic script with a sleep of 15 minutes between each interrogation. If the same jobs have been found in WRSRC status after 2 interrogations, then the following console message is issued:&lt;BR /&gt;â  CALLOUT - There are jobs stuck in WRSRC status.  Investigate job log and escalate!â  &lt;BR /&gt;&lt;BR /&gt;Issue is : I have made script in such a way that it should trigger at 01:00AM(Job will trigger it)...sleep for every 15 mins....and it will complete between 23:44 to 23:59)....however Job triggers it at 01:00 Am (GMt) and it completes right away...as per mt perception it should start @ 01:00 and complete @ night between 23:44 to 23: 59..&lt;BR /&gt;Here is the script attached:&lt;BR /&gt;&lt;BR /&gt;Please assist asap...&lt;BR /&gt;</description>
      <pubDate>Sat, 04 Jun 2011 02:45:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795408#M641391</guid>
      <dc:creator>Shikha Punyani</dc:creator>
      <dc:date>2011-06-04T02:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance with script...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795409#M641392</link>
      <description>On lines 38...49 of your script (commented "Create dummy latest file if one does not exist), the same sequence of three lines appears twice. There are three "if" statements, but only two closing "fi" keywords. &lt;BR /&gt;&lt;BR /&gt;In some situations, it might be worthwhile to make a second attempt at creating the dummy latest file if the first attempt fails, but in this case, it looks more like a copy/paste mistake.&lt;BR /&gt;&lt;BR /&gt;As a result of this mistake, the majority of the script would be skipped if ${latest_listfile} did exist when the script was started.&lt;BR /&gt;&lt;BR /&gt;Your attached script used a very strange and un-helpful indentation scheme. I let my Vim editor re-indent it using its default indentation rules for shell scripts. The result is much easier to follow. &lt;BR /&gt;&lt;BR /&gt;Vim also helped me to find the above-mentioned mistake: its syntax highlighting coloured the "done" on line 95 with white-on-red to indicate an error. The syntax highlighting keeps track of command structures like if...then...else...fi, do...done and case...esac. On line 95, it was expecting another "fi" before "done", and flagged the "done" as an error because of that.&lt;BR /&gt;&lt;BR /&gt;Attached is a fixed and re-indented version of your script.&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Sat, 04 Jun 2011 09:12:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795409#M641392</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2011-06-04T09:12:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance with script...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795410#M641393</link>
      <description>Hi,&lt;BR /&gt;Thanks for replying...I really need to to this one ASAp..&lt;BR /&gt;Apologies for my mistake.. I think I paste the old sript.. attached is the one which is on server...&lt;BR /&gt;Can you please have a look at it now?</description>
      <pubDate>Sat, 04 Jun 2011 09:24:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795410#M641393</guid>
      <dc:creator>Shikha Punyani</dc:creator>
      <dc:date>2011-06-04T09:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance with script...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795411#M641394</link>
      <description>Please check this attachment..Ignore the last one..</description>
      <pubDate>Sat, 04 Jun 2011 09:28:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795411#M641394</guid>
      <dc:creator>Shikha Punyani</dc:creator>
      <dc:date>2011-06-04T09:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance with script...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795412#M641395</link>
      <description>Hey I got the issue&lt;BR /&gt;Firstof there are two directories in it Logs and Scripts....they did not have the wrire permissions...&lt;BR /&gt;Now one challenge which I am facing is&lt;BR /&gt;Script is running when I login with sudo and type &lt;BR /&gt;sh -x script name....&lt;BR /&gt;However how can I run it as a sudo from JOb...&lt;BR /&gt;Job is using normal username and password&lt;BR /&gt;and If I will add&lt;BR /&gt;sudo su - in script it will wait for someone to enter password..&lt;BR /&gt;how do I go about it?&lt;BR /&gt;</description>
      <pubDate>Sat, 04 Jun 2011 10:51:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795412#M641395</guid>
      <dc:creator>Shikha Punyani</dc:creator>
      <dc:date>2011-06-04T10:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance with script...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795413#M641396</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; However how can I run it as a sudo from JOb&lt;BR /&gt;&lt;BR /&gt;If want the 'JOb' user to be able to execute your script edit the 'sudoers' file to allow your script.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Sat, 04 Jun 2011 12:11:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795413#M641396</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-06-04T12:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance with script...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795414#M641397</link>
      <description>&lt;!--!*#--&gt;&amp;gt;Ignore the last one.&lt;BR /&gt;&lt;BR /&gt;As MK mentioned please fix your indentation.  This helps you and us understand your script better.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;while [ `date +%H%M` -le 2359 -o `date +%H%M` -ge 0100 ]; do&lt;BR /&gt;&lt;BR /&gt;This range check isn't useful.  Why not replace it by: :-)&lt;BR /&gt;while true; do&lt;BR /&gt;&lt;BR /&gt;You probably want:&lt;BR /&gt;while (( $(date +%H%M) &amp;gt;= 0100 &amp;amp;&amp;amp; $(date +%H%M) &amp;lt;= 2359 )); do&lt;BR /&gt;&lt;BR /&gt;Note: The AND.  And I usually put the lower bound first.&lt;BR /&gt;Your other range check seems fine.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;# Pre-delete Files&lt;BR /&gt;&amp;gt;if [ -f ${old_listfile} ]&lt;BR /&gt;&lt;BR /&gt;Why work so hard?&lt;BR /&gt;rm -f ${old_listfile}&lt;BR /&gt;if [ $? -ne 0 ]; then&lt;BR /&gt;   echo "Delete of ${old_listfile} failed"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;Add mv -f here:&lt;BR /&gt;mv ${latest_listfile} ${old_listfile}&lt;BR /&gt;&lt;BR /&gt;&amp;gt;grep "${jobset} ${job} ${jno} ${qual}" $old_listfile &amp;gt;&amp;gt;/dev/null&lt;BR /&gt;&lt;BR /&gt;Better to use grep -q:&lt;BR /&gt;grep -q "${jobset} ${job} ${jno} ${qual}" $old_listfile&lt;BR /&gt;&lt;BR /&gt;And can remove the evil cat from:&lt;BR /&gt;cat $latest_listfile | while read jobset job jno qual;  do&lt;BR /&gt;&lt;BR /&gt;while read jobset job jno qual; do&lt;BR /&gt;...&lt;BR /&gt;done &amp;lt; $latest_listfile</description>
      <pubDate>Sat, 04 Jun 2011 16:39:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795414#M641397</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-06-04T16:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: Need assistance with script...</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795415#M641398</link>
      <description>&amp;gt;ME: while (( $(date +%H%M) &amp;gt;= 0100 &amp;amp;&amp;amp; $(date +%H%M) &amp;lt;= 2359 )); do&lt;BR /&gt;&lt;BR /&gt;You may have to change 0100 to 100, the posix shell may convert this to stinkin' octal.</description>
      <pubDate>Sat, 04 Jun 2011 16:45:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/need-assistance-with-script/m-p/4795415#M641398</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2011-06-04T16:45:07Z</dc:date>
    </item>
  </channel>
</rss>

