I work at a large site with hundreds of different computers and printers, each with their own setups and I have lately been running into the problem where the printer que on a given system will get paused and all of the print jobs get jammed up for that computer.
I have figured out how to clear out the queues on the computers, however what I have yet to figure out is how to get the script to dynamically detect all printer queues on the system and restart the ones that are disabled.
I have written this script here and admittedly I am still just learning how to script in Unix/applescript I think this should work and am currently at a loss as to why it doesn’t.
If anyone out there could help me figure out why this does not work right then it would be a huge help for me.
set thePrinters to (do shell script "lpstat -p | grep disabled | /usr/bin/awk '{print $2}'")
if length of thePrinters > 0 then
repeat with x in thePrinters
do shell script "/usr/sbin/cupsenable " & x
end repeat
end if
However when I run it I get this apple script error “cupsenable: Operation failed: client-error-not-found”
I can run the cupsenable unix command from the command line from the command line with the individual output I am getting from the “lpstat -p | grep disabled | /usr/bin/awk ‘{print $2}’” command however when I run it through the script I get this issue.
I know this is only going to work on a 10.5, as I understand it I will need to change it to this:
set thePrinters to (do shell script "lpstat -p | grep disabled | /usr/bin/awk '{print $2}'")
if length of thePrinters > 0 then
repeat with x in thePrinters
do shell script "/usr/bin/enable " & x
end repeat
end if
If I want it to work on 10.4.
Ultimately I will want to find a way for it to run the appropriate commands depending on what environment it is running in, since I have both 10.4 and 10.5 systems and would like to be able to use the same scripts in either case.
If anyone has any advice on this it would be greatly appreciated.
Thank you