I have a plistbuddy command that I need to execute for 100 different users.
The value I have to enter for the 100 individual users depends on the hostname.
I was thinking I could use a csv that has a list of the hostnames/computernames and the corresponding plist value, then use a shell script to:
- Check for the hostname of the Mac
- Find the hostname in the csv
- find the value of the corresponding code needed for the plistbuddy command and save it to a variable
- insert that value into the plistbuddy command and execute, changing the value of the desired plist file.
The csv would just be formatted as:
Specifically the plist file is the printer preference plist file.
Here is the plistbuddy command:
/usr/libexec/PlistBuddy -c "Set :2ndfloor:com.apple.print.preset.settings:ManagementCodeValue 1001" ~/Library/Preferences/com.apple.print.custompresets.forprinter.CMI2ndFloorColor.plist
The value that needs to change depending on the hostname is the value "1001" in that command.
Those are the only elements; check hostname, find it in the csv, execute the plistbuddy command using the corresponding code in the csv.
Anyone have any good ideas for this? It would save hours and hours of GUI work.