Script for enabling the printer in HP-UX

Thread Tools Search this Thread
Operating Systems HP-UX Script for enabling the printer in HP-UX
# 1  
Old 02-09-2014
Script for enabling the printer in HP-UX

HI Guys

Want help in writing a Script for check and enable the printer if any any is disable in HP-UX automatic after every half hour...

# 2  
Old 02-10-2014
OK, so how did you plan to do it, or what have you tried?
# 3  
Old 02-10-2014
Try something like this to get started on the sorts of things you will need to do.

You might also like to try this

Have a read, have a go and then let us know if you need some more help with your chosen approach.

# 4  
Old 02-10-2014
Hi Guys

Please check whether the below mention scipt is fine or not to enable a disable printer…
# Script To check and enable printers that have gone down.
if [ $# = 1 ]
   lpstat $1 | grep Warning > /dev/null 2>&1
   if [ $? = 0 ]
      echo "$1 down at $date" >> /var/tmp/lp/errlog
      ps -ef | grep lp >> /var/tmp/lp/$1pslog
      tail -50 /var/spool/lp/log >> /var/tmp/lp/$1lplog
      tail -50 /var/adm/syslog/syslog.log >> /var/tmp/lp/$1syslog
      dmesg >> /var/tmp/lp/$1dmesglog
      echo "Cancelling Print Requests for $1" >> /var/tmp/lp/errlog
      cancel -a -e -i $1
      enable $1
      echo "$1 brought up at $date1" >> /var/tmp/lp/errlog
   echo Improper Usage

Moderator's Comments:
Mod Comment Please use code tags for your code and data

Last edited by vbe; 02-10-2014 at 04:31 PM.. Reason: code tags + indent
# 5  
Old 02-11-2014
I have a few observations. I apologies if listing them make it seem a little terse for a response, but I will end up in long winded discussion with myself otherwise.
  • If you are planning on scheduling this, you will have to name the printer, and therefore run it for each printer. Would you consider looking at the output of lpstat -p (no other parameters) and taking action for each printer that is not in a good state?
  • Why are you planning to cancel a print job? The output will be lost, when the most usual cause is a printer hardware issue, and the job will pick up later.
  • Very pleased to see lots of logging for actions but your tail -50 /var/spool/lp/log may not get the information you are interested in. Perhaps use grep to select information about your print queue and then tail off the last few records.
  • You are searching for state of Warning, but that doesn't cover a queue that is DOWN
These are observations only, and you certainly have the makings of a sensible approach. If it meets your needs, there is nothing else to do.


Last edited by rbatte1; 02-11-2014 at 01:09 PM.. Reason: ICODE tagging "DOWN" & splleling
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to check if printer is out of paper using perl script ?

Hello, I need to chack if the printer is out of paper, and send message to operator. I need to do this from perl script. The printer have mechanism to check if it have paper. However, the cups does not report "printer out of paper" when I remove the paper, and try to print. Is there any... (1 Reply)
Discussion started by: +Yan
1 Replies

2. UNIX for Dummies Questions & Answers

Help with script to automate CUPS printer installs

Good afternoon. :) I'm rather new to bash scripting, and have probably bitten off a bit more than I can chew to be honest, but I work in a service desk-like environment where one of the main complaints is that it takes our staff a long time to set up network printers on our clients' servers.... (3 Replies)
Discussion started by: aperfecthalo
3 Replies

3. AIX

Help with clear printer queue script in AIX 5.3

Good day UNIX forum, could you help me with my clear printer queue script, i have problems with the consistency of this function, sometimes it works sometimes it doesn't. Thanks in advance } preRemovePrintQ(){ clear; echo; echo... (1 Reply)
Discussion started by: beware187
1 Replies

4. Linux

Find printer location and printer type

Hi, Is it possible to find the printer location and printer type (whether it is local or network) using command in Linux ? Thanks in advance. (1 Reply)
Discussion started by: forumguest
1 Replies

5. Shell Programming and Scripting

Printer status script giving error

Hi, We check the printer status at the command line by giving the following command and the system gives an output; lpstat -prn001_hp4000n When I give the same command in a UNIX script the system gives an error while running the script as "lpstat: not found". Please let me know... (8 Replies)
Discussion started by: jmathew99
8 Replies

6. AIX

Check printer queue on Windows printer server

Hello Let me first give a small overview of the setup. All printers are connected to Windows 2000 servers. There are a lot of UNIX (AIX & HP-UX) servers as well which have SAP running. I'm working on a script to add printers to a specified SAP instance. I want to verify the user input (to... (0 Replies)
Discussion started by: NielsV
0 Replies

7. Shell Programming and Scripting

Need a little help with this printer up script.

Hi there all.. I need some help with a script I have. It's a printing script but what will happen if the printer stays on disabled? Will it continue in the loop? How can I change the script so it will only loop like 5 times and if still not working than it send a e-mail with what printer has... (0 Replies)
Discussion started by: draco
0 Replies

8. Shell Programming and Scripting

Enabling a script to run in multiple paths

I have a script that i need to run from different paths. for example mypc/path1/path2/, mypc/path1/path2/path3/, and mypc/path1/path2/path3/path4 How do i set up that script so that it can execute in any of the above paths or how can i make it run on any path on my computer?? (5 Replies)
Discussion started by: dowell
5 Replies
Login or Register to Ask a Question