- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Shell Script to report total print jobs for ea...
Operating System - HP-UX
1771000
Members
2492
Online
109003
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-24-2003 06:55 PM
тАО07-24-2003 06:55 PM
Re: Shell Script to report total print jobs for each que
Sorry I did not see the question earlier. The cut -d \ -f .. is a way to specify a single space as a delimiter. Unfortunately, the forums code reduces multiple spaces to just one. So when you cut-n-paste the text, it will produce the error you see. The text should read:
cut -d \space space -f ...
so leave out the apostrophes and just add an extra space after the \ char. The \ escapes the special meaning of the first space and the missing second space separates -d char from the -f option. Another way is:
cut -d ' ' -f ...
which is probably more intuitive and translates cleanly:
#!/usr/bin/sh
# Count print requests by printer
export PATH=/usr/bin
ACTIVE=0
JOBS=0
for PRINTQ in $(echo /var/spool/lp/request/*)
do
QUEUENAME=$(basename $PRINTQ)
QTY=$(ls $PRINTQ/d* 2>/dev/null | wc -l | cut -d ' ' -f 1)
if [ $QTY -gt 0 ]
then
let ACTIVE=$ACTIVE+1
print "Printer $QUEUENAME = \c"
print "$QTY request\c"
[[ $QTY -ne 1 ]] && print "s\c"
let JOBS=$JOBS+$QTY
print ""
fi
done
print "\nTotal jobs=$JOBS, printers with a queue=$ACTIVE"
(I checked a cut-n-paste from the above and it works OK)
Bill Hassell, sysadmin
cut -d \space space -f ...
so leave out the apostrophes and just add an extra space after the \ char. The \ escapes the special meaning of the first space and the missing second space separates -d char from the -f option. Another way is:
cut -d ' ' -f ...
which is probably more intuitive and translates cleanly:
#!/usr/bin/sh
# Count print requests by printer
export PATH=/usr/bin
ACTIVE=0
JOBS=0
for PRINTQ in $(echo /var/spool/lp/request/*)
do
QUEUENAME=$(basename $PRINTQ)
QTY=$(ls $PRINTQ/d* 2>/dev/null | wc -l | cut -d ' ' -f 1)
if [ $QTY -gt 0 ]
then
let ACTIVE=$ACTIVE+1
print "Printer $QUEUENAME = \c"
print "$QTY request\c"
[[ $QTY -ne 1 ]] && print "s\c"
let JOBS=$JOBS+$QTY
print ""
fi
done
print "\nTotal jobs=$JOBS, printers with a queue=$ACTIVE"
(I checked a cut-n-paste from the above and it works OK)
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-03-2004 03:01 PM
тАО11-03-2004 03:01 PM
Re: Shell Script to report total print jobs for each que
can someone explain what this line is doing?.
[[ $QTY -ne 1 ]] && print "s\c"
thanks
[[ $QTY -ne 1 ]] && print "s\c"
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2004 12:00 PM
тАО11-04-2004 12:00 PM
Re: Shell Script to report total print jobs for each que
The [[ $QTY -ne 1 ]] && print "s\c" line is a quick way to improve spelling. Instead of always saying "1 requests or "2 requests", the letter s is appended only when the quantity of requests is not 1. The 2 square brackets are used as an alternate way to test a condition, and the double ampersands is a shorthand way to say: do this if true. If two vertical bars were used, it would signify: do this if false. Both constructs can be used on the same line. The "s\c" means print "s" but do not add a new line, just leave the cursor where it is.
Bill Hassell, sysadmin
Bill Hassell, sysadmin
- « Previous
-
- 1
- 2
- Next »
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP