Operating System - HP-UX
1833784 Members
2538 Online
110063 Solutions
New Discussion

How can I delete printers with a script

 
frederick hannah
Super Advisor

How can I delete printers with a script

I have a dozen printer names in a file and the printers need to deleted. I am learning to script and have tried various "for i in" attempts to delete the printers. Nothing works and I know I am close. What is a simple way to delete several printers via scripting?
7 REPLIES 7
James R. Ferguson
Acclaimed Contributor

Re: How can I delete printers with a script

Hi:

#!/usr/bin/sh
while read NAME X
do
cmd ${NAME}
done < namesfile

...where 'namesfile' contains the printer names, one per line and 'cmd' is whatever command and flags you need together with the ${NAME} variable.

Regards!

...JRF...
frederick hannah
Super Advisor

Re: How can I delete printers with a script

No, the script responded with lpadmin -x needs a value.
frederick hannah
Super Advisor

Re: How can I delete printers with a script

Check that. It does work but i have to do some tweaking on my end.
frederick hannah
Super Advisor

Re: How can I delete printers with a script

the script generates errors, but nothing I cant handle
James R. Ferguson
Acclaimed Contributor

Re: How can I delete printers with a script

Hi (again):

#!/usr/bin/sh
while read NAME X
do
lpadmin -x${NAME}
done < namesfile

...note that 'x${NAME}' is run-together.

Regards!

...JRF...
James R. Ferguson
Acclaimed Contributor

Re: How can I delete printers with a script

Hi (again):

If you are satisified, please assign points, too.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: How can I delete printers with a script

>I have a dozen printer names in a file

Here is how to use a for loop:
for NAME in $(< namesfile); do
lpadmin -x${NAME}
done