The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > HP-UX
Google UNIX.COM


HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Include PERL script with in the unix shell script ganapati UNIX for Dummies Questions & Answers 1 04-29-2008 09:18 AM
help me in sending parameters from sqlplus script to unix shell script Hara Shell Programming and Scripting 2 01-29-2008 11:31 AM
FTP script for sending a file from one unix directory to another unix server director raja_1234 Shell Programming and Scripting 1 11-30-2006 03:57 AM
how to convert unix .ksh script to windows .batch script 2.5lt V8 Shell Programming and Scripting 1 11-28-2006 08:52 AM
check in unix shell script so that no one is able to run the script manually adi_bang76 Shell Programming and Scripting 1 11-16-2006 06:43 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-09-2008
Registered User
 

Join Date: Apr 2008
Posts: 4
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Unix Script

Guys,

I currently have a script that finds print requests older than 1 day and cancels it from the spooler.

the script goes like this:

###
PRINTERLIST="
hkgwclp0
twapthpc
twapthpb
2o2mlj5d
Itlaser
CIA_Customs
sscopslj9
sscopslj2
sscopslj8
fjnanwp1
phmnl9040"

for PRINTER in $PRINTERLIST
do
find /var/spool/lp/request/$PRINTER -mtime +0
if [ $(find /var/spool/lp/request/$PRINTER -mtime +0 | grep "$LOCAL_SERVER" | wc
-l) -gt 0 ]
then
echo "$PRINTER" >> /cia/ciaadm/bin/printer.list
/usr/local/bin/canprint $PRINTER
let cnt=cnt+1
fi
done
##

this is just a partial script.

i have a few questions:

1. Instead of hardcoding the printer names, how can i just dynamically call the printers from /var/spool/lp/request/$printer-name/?? Is there any other way?
2. How can i break down the find to look for requests older than 1 hour, instead of 1 day?

Sorry im a bit of a N00B....

Thanks all!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-09-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 2,275
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
If your find is capable enough, it will be able to give you minute granularity. If not, maybe we can develop something here.

If all the entries in /var/spool/lp/requests are the names of printers you want to connect to, and there are none there which you don't want to connect to, just loop over those then?

The wc -l is Useless

Code:
for PRINTER in /var/spool/lp/request/*
do
  if find "$PRINTER" -mmin +60 | grep "$LOCAL_SERVER" >/dev/null
  then
    echo `basename "$PRINTER"` >> /cia/ciaadm/bin/printer.list
    /usr/local/bin/canprint `basename "$PRINTER"`
    let cnt=cnt+1
  fi
done
I guess the cnt is used outside of your script somewhere ...?

Last edited by era; 04-09-2008 at 11:55 PM. Reason: oops, need basename
Reply With Quote
  #3 (permalink)  
Old 04-09-2008
Registered User
 

Join Date: Apr 2008
Posts: 4
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Quote:
Originally Posted by era View Post
If your find is capable enough, it will be able to give you minute granularity. If not, maybe we can develop something here.

If all the entries in /var/spool/lp/requests are the names of printers you want to connect to, and there are none there which you don't want to connect to, just loop over those then?

The wc -l is Useless

Code:
for PRINTER in /var/spool/lp/request/*
do
  if find "$PRINTER" -mmin +60 | grep "$LOCAL_SERVER" >/dev/null
  then
    echo `basename "$PRINTER"` >> /cia/ciaadm/bin/printer.list
    /usr/local/bin/canprint `basename "$PRINTER"`
    let cnt=cnt+1
  fi
done
era, thanks.

but mmin does not work in my version of hp-ux...im getting a "find bad option - mmin"

I do not want to complicate things by using touch

Is there any other way to break this down?

Thanks!
Reply With Quote
  #4 (permalink)  
Old 04-10-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 2,275
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Pass to Perl, maybe?

Code:
find "$PRINTER" -type f | perl -lne '@s = stat $_; print "$_" if $s[9] < $^T-3600'
Reply With Quote
  #5 (permalink)  
Old 04-10-2008
Registered User
 

Join Date: Apr 2008
Posts: 4
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Quote:
Originally Posted by era View Post
Pass to Perl, maybe?

Code:
find "$PRINTER" -type f | perl -lne '@s = stat $_; print "$_" if $s[9] < $^T-3600'

thanks again era..i will try that.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes


The 50 most popular UNIX and Linux searches.
Google Search Cloud for The UNIX and Linux Forums
"inappropriate ioctl for device" 421 service not available, remote server has closed connection ^m arg list too long ascii eof autosys awk trim bash eval bash exec bash for loop boot: cannot open kernel/sparcv9/unix command copy/move folder in unix curses.h dead.letter export display find grep grep multiple lines grep multiple words grep or grep recursive grep unique inappropriate ioctl for device logrotate.conf lynx javascript mailx attachment mget mtime perl array length ping port read awk output into multiple variables replace space by comma , perl script scp recursive segmentation fault(coredump) sftp script snoop unix stale nfs file handle syn_sent tar exclude unix unix .profile unix com unix forum unix forums unix interview questions unix memory usage unix mtime unix simulator unix.com vi tab size while loop within while loop shell script


All times are GMT -7. The time now is 04:04 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101