<?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: ksh script help in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893707#M701099</link>
    <description>Hi:&lt;BR /&gt;&lt;BR /&gt;There was a typo in the ksh script. I changed that but i still get the broken pipe error. Wonder what the issue would be?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Brian.</description>
    <pubDate>Thu, 31 Mar 2005 21:49:22 GMT</pubDate>
    <dc:creator>brian_31</dc:creator>
    <dc:date>2005-03-31T21:49:22Z</dc:date>
    <item>
      <title>ksh script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893701#M701091</link>
      <description>Team:&lt;BR /&gt;&lt;BR /&gt;I need to get this done in ksh script. I have the&lt;BR /&gt;following output from lpstat -o (we are trying to &lt;BR /&gt;capture the jobs which are in the print queue for 7&lt;BR /&gt;days or more). lpstat -o output is attached. Please&lt;BR /&gt;help.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Brian.&lt;BR /&gt;</description>
      <pubDate>Thu, 31 Mar 2005 15:45:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893701#M701091</guid>
      <dc:creator>brian_31</dc:creator>
      <dc:date>2005-03-31T15:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893702#M701092</link>
      <description>Hi again:&lt;BR /&gt;&lt;BR /&gt;We are trying to capture the jobs which are 7 days or more in the queue and email them to admins.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Brian</description>
      <pubDate>Thu, 31 Mar 2005 15:46:11 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893702#M701092</guid>
      <dc:creator>brian_31</dc:creator>
      <dc:date>2005-03-31T15:46:11Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893703#M701093</link>
      <description>&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;7day_back=`perl -e '$sevenday = localtime(time-24*60*60),print "$sevenday\n"'|awk '{print $2, $3}'`&lt;BR /&gt;&lt;BR /&gt;lpstat -o | grep "${7day_bak}"&lt;BR /&gt;&lt;BR /&gt;Anil</description>
      <pubDate>Thu, 31 Mar 2005 16:07:29 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893703#M701093</guid>
      <dc:creator>RAC_1</dc:creator>
      <dc:date>2005-03-31T16:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893704#M701094</link>
      <description>This should work... but I can't test it much b/c my queues are pretty clean right now...&lt;BR /&gt;&lt;BR /&gt;#!/bin/ksh&lt;BR /&gt;export HNAME=`/bin/hostname`&lt;BR /&gt;cd /var/spool/lp/request&lt;BR /&gt;for i in `find . -type f -name "cA*${HNAME}" -mtime +7`&lt;BR /&gt;do&lt;BR /&gt;   printer=`echo $i | cut -f 2 -d"/"`&lt;BR /&gt;   job=`echo $i | cut -f 3 -d"/"| sed -e "s/^cA//" -e "s/$HNAME//"`&lt;BR /&gt;   echo Print Job $job on printer $printer is older than 7 days&lt;BR /&gt;done  | mailx -s "OLD PRINT JOBS" admin@urcompany.com&lt;BR /&gt;</description>
      <pubDate>Thu, 31 Mar 2005 16:19:46 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893704#M701094</guid>
      <dc:creator>TwoProc</dc:creator>
      <dc:date>2005-03-31T16:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893705#M701095</link>
      <description>Thanks. I also need to email the results to admins. PLUS i need the script to work on the output that i have given. Please help&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Brian</description>
      <pubDate>Thu, 31 Mar 2005 16:27:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893705#M701095</guid>
      <dc:creator>brian_31</dc:creator>
      <dc:date>2005-03-31T16:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893706#M701096</link>
      <description>the mailx command at the end of the script I sent will send out the mail...&lt;BR /&gt;The script I wrote doesn't use your output - &lt;BR /&gt;it uses the fact that those files will reside in the output queue directories to create a simple find command to do the work.&lt;BR /&gt;But, it should be a simple thing to get the one Anil posted to work just pipe it to mailx command like I have at the end of the command I posted above.</description>
      <pubDate>Thu, 31 Mar 2005 18:19:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893706#M701096</guid>
      <dc:creator>TwoProc</dc:creator>
      <dc:date>2005-03-31T18:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893707#M701099</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;There was a typo in the ksh script. I changed that but i still get the broken pipe error. Wonder what the issue would be?&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;Brian.</description>
      <pubDate>Thu, 31 Mar 2005 21:49:22 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893707#M701099</guid>
      <dc:creator>brian_31</dc:creator>
      <dc:date>2005-03-31T21:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893708#M701102</link>
      <description>Think that you should remove it!</description>
      <pubDate>Fri, 01 Apr 2005 00:17:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893708#M701102</guid>
      <dc:creator>Hoang Chi Cong_1</dc:creator>
      <dc:date>2005-04-01T00:17:27Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893709#M701105</link>
      <description>hi:&lt;BR /&gt;&lt;BR /&gt;This is what i get when i execute the script&lt;BR /&gt;&lt;BR /&gt;$./print.sh&lt;BR /&gt;./print.sh[4]: 7day_back=Mar:  not found&lt;BR /&gt;./print.sh[6]: "${7day_back}": bad substitution&lt;BR /&gt;$Broken Pipe&lt;BR /&gt;&lt;BR /&gt;Please help&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Apr 2005 07:56:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893709#M701105</guid>
      <dc:creator>brian_31</dc:creator>
      <dc:date>2005-04-01T07:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893710#M701107</link>
      <description>you can NOT have numbers as the first chracter in a variable name!&lt;BR /&gt;&lt;BR /&gt;SevenDaysBack=`perl -e '$sevenday = localtime(time-(7*24*60*60));print "$sevenday\n"'|awk '{print $2, $3}'`&lt;BR /&gt;&lt;BR /&gt;and of course 7 days back is time - (7 * 24 * 60 *60)&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry d brown jr</description>
      <pubDate>Fri, 01 Apr 2005 08:26:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893710#M701107</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2005-04-01T08:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893711#M701109</link>
      <description>Just don't start the name of a variable with a digit. ksh expects that to be a standard variable passed to the script at the commandline. ($0 - $9)&lt;BR /&gt;Change 7days_back to days_back or sevendays_back&lt;BR /&gt;&lt;BR /&gt;Good luck</description>
      <pubDate>Fri, 01 Apr 2005 08:27:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893711#M701109</guid>
      <dc:creator>Henk Pilon</dc:creator>
      <dc:date>2005-04-01T08:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893712#M701110</link>
      <description>anil/all:&lt;BR /&gt;&lt;BR /&gt;I am getting null string for $sevenday $2 and $3 these are also null. please help.&lt;BR /&gt;&lt;BR /&gt;Thanks&lt;BR /&gt;&lt;BR /&gt;brian&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Apr 2005 10:22:07 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893712#M701110</guid>
      <dc:creator>brian_31</dc:creator>
      <dc:date>2005-04-01T10:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893713#M701111</link>
      <description>What do you get when you run this:&lt;BR /&gt;&lt;BR /&gt;perl -e '$sevenday = localtime(time-(7*24*60*60));print "$sevenday\n"'|awk '{print $2, $3}'&lt;BR /&gt;&lt;BR /&gt;or this:&lt;BR /&gt;&lt;BR /&gt;perl -e '$sevenday = localtime(time-(7*24*60*60));print "$sevenday\n"'&lt;BR /&gt;&lt;BR /&gt;live free or die&lt;BR /&gt;harry d brown jr</description>
      <pubDate>Fri, 01 Apr 2005 10:50:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893713#M701111</guid>
      <dc:creator>harry d brown jr</dc:creator>
      <dc:date>2005-04-01T10:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893714#M701112</link>
      <description>Hmmm,&lt;BR /&gt;&lt;BR /&gt;that $sevendays thing works fine for me:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; ksh&lt;BR /&gt;$ SevenDaysBack=`perl -e '$sevenday = localtime(time-(7*24*60*60));print "$seven&lt;BR /&gt;day\n"'|awk '{print $2, $3}'`&lt;BR /&gt;&lt;BR /&gt;$ echo $SevenDaysBack&lt;BR /&gt;Mar 25&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;fwiw, Personally it rubs me the wrong way to follow perl with awk when a trivial perl solution is available. For example:&lt;BR /&gt;&lt;BR /&gt;$ perl -e '$_ = localtime(time-(7*24*60*60)); @old=split; print "$old[1] $old[2]&lt;BR /&gt;\n"'&lt;BR /&gt;Mar 25&lt;BR /&gt;$&lt;BR /&gt;&lt;BR /&gt;To carry that theme forward, why not compare the dates in perl? Now the 'Mar 31' style date is hard to compare. So first convert it to seconds. Then compare with current time in seconds minus cutoff time. I don't know how to have perl do month-string to month-number nicely (Language independend, so I cheated and hardcoded a month table:&lt;BR /&gt;&lt;BR /&gt;Start of a solution:&lt;BR /&gt;&lt;BR /&gt;---- find_old.p ----&lt;BR /&gt;use Time::Local;&lt;BR /&gt;$year = (localtime)[5];&lt;BR /&gt;while (&amp;lt;&amp;gt;){&lt;BR /&gt;if (/(\w+)\s+(\d+)\s+(\d+):(\d+)$/) {&lt;BR /&gt;  $mon = index("JanFebMarAprMayJunJulAugSepOctNovDec",$1)/3;&lt;BR /&gt;  $t = timelocal(0,$4,$3,$2,$mon,$year);&lt;BR /&gt;  print if ($t &amp;lt; time - (7*24*60*60))&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;---- sample output for slightly editted input sample ---&lt;BR /&gt;&lt;BR /&gt;perl find_old.p  lpstat.txt&lt;BR /&gt;brflora-295            aflorad1@essdbdu31    4330   Mar 21 19:30&lt;BR /&gt;brflora-298            aflorad1@essdbdu31    5444   Feb  2 19:30&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;It should be straight forwards to just print names, numbers, or email from that perl script.&lt;BR /&gt;&lt;BR /&gt;Good luck,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Apr 2005 11:17:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893714#M701112</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2005-04-01T11:17:36Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893715#M701113</link>
      <description>Brian,&lt;BR /&gt;&lt;BR /&gt;I know that you are focused on the lpstat command. &lt;BR /&gt;I approached the problem differently&lt;BR /&gt;cd /var/spool/lp/request&lt;BR /&gt;find . -type file -mtime -7 -print&lt;BR /&gt;and then process that list.&lt;BR /&gt;&lt;BR /&gt;good luck &lt;BR /&gt;Rory</description>
      <pubDate>Fri, 01 Apr 2005 13:09:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893715#M701113</guid>
      <dc:creator>Rory R Hammond</dc:creator>
      <dc:date>2005-04-01T13:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: ksh script help</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893716#M701114</link>
      <description>Thanks Harry, Hein. It works. What a Forum this is!!!! Unbeleivable.&lt;BR /&gt;&lt;BR /&gt;Thanks a ton&lt;BR /&gt;&lt;BR /&gt;Brian</description>
      <pubDate>Fri, 01 Apr 2005 13:29:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/ksh-script-help/m-p/4893716#M701114</guid>
      <dc:creator>brian_31</dc:creator>
      <dc:date>2005-04-01T13:29:10Z</dc:date>
    </item>
  </channel>
</rss>

