scripting around lpadmin

Paul pconklin at gentlemanslife.com
Fri Jan 21 20:23:48 PST 2011


I've written a ksh script that parses through a CSV and then builds printers in both a Database (for the application) and in CUPS.  Now that I have functionality built, i've started primate proofing it and hit a brick wall.  I'm trying to redirect output of the lpadmin commmand so I can see if it failed (i.e. CUPS was stopped) but for the life of me I can't get it to re-direct.  Things i've tried:
CStat=$(lpadmin -ptestprinter -D"This is a Test" -vsocket://testprinter:9100 -E)
lpadmin -ptestprinter -D"This is a Test" -vsocket://testprinter:9100 -E >> test.txt
lpadmin>>test.txt -ptestprinter -D"This is a Test" -vsocket://testprinter:9100 -E
lpadmin -ptestprinter -D"This is a Test" -vsocket://testprinter:9100 -E | everyconcievable command I could think

but it always is null.

Anyone else have an idea on how to get it to redirect?  the message it reports back at least if CUPS is not running is:
lpadmin: Unable to connect to server: Connection refused

While I can code around other ways to ensure CUPS is running, I was more hoping to just make a catch all to cover anyway that lpadmin may fail.  basically if it returns anything...it failed, else, worked

Thanks in advance for any suggestions.




More information about the cups mailing list