Just trying to run a script on machines that deletes all the garbage entries of printers that JAMF School has put onto systems while trying to manage/add printers in the JAMF Cloud web interface (which is actually a nightmare since there is no real documentation other than "just do this" and nothing is actually validated before it is pushed to systems). Even though I removed the printers in JAMF, the printers still show up as local entries on each machine and I can also do lplist which dumps all the printer entries that were added to CUPS from JAMF. I can also see all the printers in CUPS WebUI.
Now, I just want to a simple bash script that is sent to each machine once to fully clear the printers so I can make one more push in JAMF as a clean slate for printers here on out. Scripting Module is enabled and works(already tested).
Here are two versions of a simple looping script I have tried to run - both fail:
#!/bin/bash
lpstat -p | awk '{print $2}' | while read printer
do
echo "Deleting Printer:" $printer
lpadmin -x $printer
done
ERRORS from JAMF:
1:233: execution error: /Library/Application Support/ZuluDesk Scripting/com.zuludesk.scripting.8f682a35-7629-11ed-b773-027c376c5399/com.zuludesk.scripting.8f682a35-7629-11ed-b773-027c376c5399.command: line 2:
: command not found
/Library/Application Support/ZuluDesk Scripting/com.zuludesk.scripting.8f682a35-7629-11ed-b773-027c376c5399/com.zuludesk.scripting.8f682a35-7629-11ed-b773-027c376c5399.command: line 7: syntax error near unexpected token `done'
/Library/Application Support/ZuluDesk Scripting/com.zuludesk.scripting.8f682a35-7629-11ed-b773-027c376c5399/com.zuludesk.scripting.8f682a35-7629-11ed-b773-027c376c5399.command: line 7: `done' (2)
Here is the second:
for printer in `lpstat -p | awk '{print $2}'`
do
echo Deleting $printer
lpadmin -x $printer
done
ERRORS from JAMF:
1:233: execution error: /Library/Application Support/ZuluDesk Scripting/com.zuludesk.scripting.8f682a35-7629-11ed-b773-027c376c5399/com.zuludesk.scripting.8f682a35-7629-11ed-b773-027c376c5399.command: line 2: syntax error near unexpected token `do
'
/Library/Application Support/ZuluDesk Scripting/com.zuludesk.scripting.8f682a35-7629-11ed-b773-027c376c5399/com.zuludesk.scripting.8f682a35-7629-11ed-b773-027c376c5399.command: line 2: `do
' (2)
Now, the first script was actually pulled from here on JAMF Nation. Just really getting under my skin since I am getting command problems yet I can run either of these scripts locally on a machine without problems.
I could use a hand here.