Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Automatically generate printer lists at login' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Automatically generate printer lists at login
Authored by: wll on Aug 08, '06 09:33:46PM

I ran into this posting from a search to delete all the CUPS printers defined on the system. I think that I can simplify your shell script.

Try: "cat /etc/printcap | grep -v '^#' | cut -d'|' -f1 | xargs lpadmin -x" which will do the same as your script. The idea is to list everything in the /etc/printcap file (the cat), delete any comment lines (the grep), get only the print queue name (the cut), and finally execute "lpadmin -x" command on each of the resulting print queue names.

Granted, this single line has a lot of potential gotcha's. For example, I would be worried that a print queue name could contain space characters or tabs, and I would want to enclose these names in quote marks. I am also assuming that the contents of the /etc/printcap file is extremely simple which may be a very poor assumption. But it does show that all of your individual lines can be simplified to a single command line.



[ Reply to This | # ]