<?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: Help with script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script/m-p/2534901#M890344</link>
    <description>Hi Nick,&lt;BR /&gt;&lt;BR /&gt;i would replace the part:&lt;BR /&gt;&lt;BR /&gt;lpstat -o|grep echeck1 &amp;gt;&amp;gt; /tmp/echeckyes &lt;BR /&gt;grep echeck1 /tmp/echeckyes &lt;BR /&gt;if [ $RETVAL -ne 0 ] &lt;BR /&gt;&lt;BR /&gt;with:&lt;BR /&gt;&lt;BR /&gt;if [ $(lpstat -t | grep -c echeck1-) ]&lt;BR /&gt;&lt;BR /&gt;This will do the following. In the lpstat if there is a job for the printer echeck1 it will have the jobid echeck1-12345 or so. With the grep command you look for those jobid's and count them (-c). If there is no job the result will be 0 or false. If there is one or more job in the queue the result will be 1 or higher which means true.&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Stefan</description>
    <pubDate>Thu, 31 May 2001 11:06:14 GMT</pubDate>
    <dc:creator>Stefan Schulz</dc:creator>
    <dc:date>2001-05-31T11:06:14Z</dc:date>
    <item>
      <title>Help with script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script/m-p/2534900#M890343</link>
      <description>Experts,&lt;BR /&gt;&lt;BR /&gt;I am trying to write a script that will run every 1/2 hour through cron that will check to see if someone submits a print job to a specific printer.  If it finds a print job, then it will send me an email, otherwise, it would just go away and sleep until the next time.&lt;BR /&gt;&lt;BR /&gt;This is what I have so far and the part I have a problem with is the if command.  If it finds a print job going to , then send email.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;#&lt;BR /&gt;&lt;BR /&gt;RETVAL=0&lt;BR /&gt;PATH=$PATH:/usr/sam/lbin:/usr/sam/bin:/usr/bin:/usr/sbin:/sbin;export PATH&lt;BR /&gt;#&lt;BR /&gt;echo "Subject: Check printer user"`date` &amp;gt;&amp;gt;/tmp/echkmail.$$&lt;BR /&gt;echo "This routine is about to check the EW Cheque printer for : " &amp;gt;&amp;gt;/tmp/echkmail.$$&lt;BR /&gt;echo "Users that are not authorized to use it.!! " &amp;gt;&amp;gt;/tmp/echkmail.$$&lt;BR /&gt;echo " " &amp;gt;&amp;gt; /tmp/echkmail.$$&lt;BR /&gt;lpstat -o|grep echeck1 &amp;gt;&amp;gt; /tmp/echeckyes&lt;BR /&gt;grep echeck1 /tmp/echeckyes&lt;BR /&gt;if [ $RETVAL -ne 0 ]&lt;BR /&gt;then&lt;BR /&gt;sendmail nickd &amp;lt; /tmp/echeckyes&lt;BR /&gt;else&lt;BR /&gt;        echo "No echeck1 print files found" &amp;gt;&amp;gt; /tmp/echkmail.$$&lt;BR /&gt;fi&lt;BR /&gt;#&lt;BR /&gt;# mail out results&lt;BR /&gt;#&lt;BR /&gt;sendmail nickd &amp;lt; /tmp/echkmail.$$&lt;BR /&gt;sendmail nickd &amp;lt; /tmp/echeckyes.$$&lt;BR /&gt;#rm /tmp/echkmail*&lt;BR /&gt;&lt;BR /&gt;Suggestions are always appreciated,&lt;BR /&gt;&lt;BR /&gt;ND</description>
      <pubDate>Thu, 31 May 2001 10:42:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script/m-p/2534900#M890343</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2001-05-31T10:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: Help with script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script/m-p/2534901#M890344</link>
      <description>Hi Nick,&lt;BR /&gt;&lt;BR /&gt;i would replace the part:&lt;BR /&gt;&lt;BR /&gt;lpstat -o|grep echeck1 &amp;gt;&amp;gt; /tmp/echeckyes &lt;BR /&gt;grep echeck1 /tmp/echeckyes &lt;BR /&gt;if [ $RETVAL -ne 0 ] &lt;BR /&gt;&lt;BR /&gt;with:&lt;BR /&gt;&lt;BR /&gt;if [ $(lpstat -t | grep -c echeck1-) ]&lt;BR /&gt;&lt;BR /&gt;This will do the following. In the lpstat if there is a job for the printer echeck1 it will have the jobid echeck1-12345 or so. With the grep command you look for those jobid's and count them (-c). If there is no job the result will be 0 or false. If there is one or more job in the queue the result will be 1 or higher which means true.&lt;BR /&gt;&lt;BR /&gt;Hope this helps. Stefan</description>
      <pubDate>Thu, 31 May 2001 11:06:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script/m-p/2534901#M890344</guid>
      <dc:creator>Stefan Schulz</dc:creator>
      <dc:date>2001-05-31T11:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: Help with script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script/m-p/2534902#M890345</link>
      <description>Hi Nick:&lt;BR /&gt;&lt;BR /&gt;The problem is that your not really testing the return value from the 'grep' of the 'lpstat' call.  Try something like this:&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;lpstat -o|grep echeck1 &amp;gt; /dev/null&lt;BR /&gt;if [ $? -eq 1 ]&lt;BR /&gt;then&lt;BR /&gt;  echo "nothing found"&lt;BR /&gt;else&lt;BR /&gt;  echo "found a match"&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;The idea of redirecting the output to /dev/null is simply that you don't need anything more than the true/false result which you test as above.&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt; &lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Thu, 31 May 2001 11:14:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script/m-p/2534902#M890345</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2001-05-31T11:14:42Z</dc:date>
    </item>
    <item>
      <title>Re: Help with script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script/m-p/2534903#M890346</link>
      <description>Or simply :&lt;BR /&gt;&lt;BR /&gt;if lpstat -o | grep -q echeck1&lt;BR /&gt;then &lt;BR /&gt;  echo "nothing found" &lt;BR /&gt;else &lt;BR /&gt;  echo "found a match" &lt;BR /&gt;fi &lt;BR /&gt;</description>
      <pubDate>Thu, 31 May 2001 11:21:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script/m-p/2534903#M890346</guid>
      <dc:creator>Laurent Paumier</dc:creator>
      <dc:date>2001-05-31T11:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: Help with script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script/m-p/2534904#M890347</link>
      <description>Can't you just review the lp log?  On my system I can do this:&lt;BR /&gt;&lt;BR /&gt;grep printername /var/adm/lp/log&lt;BR /&gt;&lt;BR /&gt;It shows all past print jobs, with usernames, dates and times, like this:&lt;BR /&gt;&lt;BR /&gt;xplr-2229   xdk1   xplr    May 31 09:28&lt;BR /&gt;&lt;BR /&gt;Fred&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 31 May 2001 12:46:31 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/help-with-script/m-p/2534904#M890347</guid>
      <dc:creator>Fred Martin_1</dc:creator>
      <dc:date>2001-05-31T12:46:31Z</dc:date>
    </item>
  </channel>
</rss>

