<?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: A new script is required in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065620#M306624</link>
    <description>Of course it seems to hang. It does a sleep 900 (15 minutes) and then looks to see if any of the same jobs are still in the queue and then repeats. It never exits unless an error is encountered or a signal is received.&lt;BR /&gt;I suspect your production version will be started/stop by an rc script. For testing purposes reduce the DELAY to something like 15 seconds and intentionally disable one of your print queues.</description>
    <pubDate>Mon, 10 Sep 2007 12:16:11 GMT</pubDate>
    <dc:creator>A. Clay Stephenson</dc:creator>
    <dc:date>2007-09-10T12:16:11Z</dc:date>
    <item>
      <title>A new script is required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065614#M306618</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I am being asked if it is possible to script a cron job so that it will check our print queues for jobs that have been sitting idle for 15 minutes.&lt;BR /&gt;&lt;BR /&gt;The script is also required to email the person who submitted the print job.  I am currently using /etc/mail/aliases on the local machine.&lt;BR /&gt;&lt;BR /&gt;Any suggestions?&lt;BR /&gt;&lt;BR /&gt;Thanks</description>
      <pubDate>Wed, 05 Sep 2007 10:39:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065614#M306618</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2007-09-05T10:39:22Z</dc:date>
    </item>
    <item>
      <title>Re: A new script is required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065615#M306619</link>
      <description>First you need to define "idle". Unless that term is precisely defined then you can't begin to write a script.&lt;BR /&gt;&lt;BR /&gt;What you could try is the output of lpstat -o and compare it to the output of 15 minutes ago. This isn't foolproof because some printjobs take much longer than 15 minutes to complete. It also makes a difference if these are Network printers, Remote printers, or directly-attached printers. In the case of Network printers, enabling true end of job might appear to be an answer but that will usually create far more problems than it solves. The mailing part is trivially easy as the lpstat -o output has everything you need (except perhaps a UNIX user to mail address lookup but that can be a simple file).</description>
      <pubDate>Wed, 05 Sep 2007 10:53:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065615#M306619</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-09-05T10:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: A new script is required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065616#M306620</link>
      <description>Thanks Clay.&lt;BR /&gt;&lt;BR /&gt;Good point on the idle question.&lt;BR /&gt;&lt;BR /&gt;I would like to do an lpstat -0 every 15 minutes and if the print job was submitted more than 15 minutes ago, to send an email to the submitter:  here is an example&lt;BR /&gt;&lt;BR /&gt;istatux /home1/nickd root lpstat -o&lt;BR /&gt;kit1-494            root           priority 0  Sep  5 11:33&lt;BR /&gt;        (standard input)                         5092 bytes&lt;BR /&gt;&lt;BR /&gt;I sent this job at 11:33 and if I was to have a script that ran now, I would like an email sent to root in this case as root submitted the job.</description>
      <pubDate>Wed, 05 Sep 2007 11:22:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065616#M306620</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2007-09-05T11:22:48Z</dc:date>
    </item>
    <item>
      <title>Re: A new script is required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065617#M306621</link>
      <description>You should really do this on your own but this should get you started:&lt;BR /&gt;&lt;BR /&gt;------------------------------------------&lt;BR /&gt;#!/usr/bin/sh&lt;BR /&gt;&lt;BR /&gt;export PATH=${PATH}:/usr/bin&lt;BR /&gt;&lt;BR /&gt;typeset PROG=${0##*/}&lt;BR /&gt;typeset TDIR=${TMPDIR:-/var/tmp}&lt;BR /&gt;typeset TF1=${TDIR}/X${$}_1.lp&lt;BR /&gt;typeset TF2=${TDIR}/X${$}_2.lp&lt;BR /&gt;typeset -i DELAY=900 # seconds&lt;BR /&gt;typeset -i STAT=0&lt;BR /&gt;typeset JOB=""&lt;BR /&gt;typeset USER=""&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;trap 'eval rm -f ${TF1} ${TF2}; exit' 0 1 2 3 15&lt;BR /&gt;&lt;BR /&gt;lpstat -o | awk '{if ($1 ~ "^[A-Za-z0-9].+-[0-9]+$") {print $0}}' &amp;gt; ${TF1}  &lt;BR /&gt;STAT=${?}&lt;BR /&gt;if [[ ${STAT} -ne 0 ]]&lt;BR /&gt;  then&lt;BR /&gt;    echo "${PROG}: lpstat failed; status ${STAT}." &amp;gt;&amp;amp;2&lt;BR /&gt;  fi&lt;BR /&gt;while [[ 1 -eq 1 &amp;amp;&amp;amp; ${STAT} -eq 0 ]]&lt;BR /&gt;  do&lt;BR /&gt;    sleep ${DELAY}&lt;BR /&gt;    lpstat -o | awk '{if ($1 ~ "^[A-Za-z0-9].+-[0-9]+$") {print $0}}' &amp;gt; ${TF2}  &lt;BR /&gt;    awk '{print $1}' ${TF1} | while read JOB&lt;BR /&gt;      do&lt;BR /&gt;        awk -v job="${JOB}" \&lt;BR /&gt;          '{if ($1 == job) {print $2; exit(0)}}' ${TF2} | while read USER&lt;BR /&gt;            do&lt;BR /&gt;              echo "Send mail to ${USER} about printjob ${JOB}"&lt;BR /&gt;            done&lt;BR /&gt;      done&lt;BR /&gt;    mv ${TF2} ${TF1}&lt;BR /&gt;    STAT=${?}&lt;BR /&gt;    if [[ ${STAT} -ne 0 ]]&lt;BR /&gt;      then&lt;BR /&gt;        echo "${PROG}: mv failed; status ${STAT}." &amp;gt;&amp;amp;2&lt;BR /&gt;      fi&lt;BR /&gt;  done&lt;BR /&gt;exit ${STAT}&lt;BR /&gt;&lt;BR /&gt;-------------------------------------------&lt;BR /&gt;You don't really have to keep up with the times. You simply do an lpstat -o and save the important data to a file, TF1. Wait 15 minutes and do the same operation and capture the lpstat output in TF2. Now read TF1 and see if printername-jobno is still in both files and if so send mail to the user.&lt;BR /&gt;Finally mv TF2 to TF1 and repeat. I'll leave the mailing up to you as that part is trivially easy.</description>
      <pubDate>Wed, 05 Sep 2007 14:02:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065617#M306621</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-09-05T14:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: A new script is required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065618#M306622</link>
      <description>It might make it a bit easier if I attach it so that you don't lose spacing and linefeeds.</description>
      <pubDate>Wed, 05 Sep 2007 14:17:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065618#M306622</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-09-05T14:17:01Z</dc:date>
    </item>
    <item>
      <title>Re: A new script is required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065619#M306623</link>
      <description>Clay,&lt;BR /&gt;&lt;BR /&gt;The script seems to hang for some reason, not sure why.&lt;BR /&gt;&lt;BR /&gt;Sorry, I am not much of a scripter so I don't even know where to begin to look.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 10 Sep 2007 11:38:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065619#M306623</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2007-09-10T11:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: A new script is required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065620#M306624</link>
      <description>Of course it seems to hang. It does a sleep 900 (15 minutes) and then looks to see if any of the same jobs are still in the queue and then repeats. It never exits unless an error is encountered or a signal is received.&lt;BR /&gt;I suspect your production version will be started/stop by an rc script. For testing purposes reduce the DELAY to something like 15 seconds and intentionally disable one of your print queues.</description>
      <pubDate>Mon, 10 Sep 2007 12:16:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065620#M306624</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2007-09-10T12:16:11Z</dc:date>
    </item>
    <item>
      <title>Re: A new script is required</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065621#M306625</link>
      <description>What a dolt I am.&lt;BR /&gt;&lt;BR /&gt;Sorry about that.&lt;BR /&gt;&lt;BR /&gt;Thanks, it works fine.&lt;BR /&gt;&lt;BR /&gt;Thanks Clay.</description>
      <pubDate>Mon, 10 Sep 2007 12:37:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/a-new-script-is-required/m-p/4065621#M306625</guid>
      <dc:creator>Nick D'Angelo</dc:creator>
      <dc:date>2007-09-10T12:37:24Z</dc:date>
    </item>
  </channel>
</rss>

