From 3944c4fd8d5134ce63defbf15499a102422b7ebc Mon Sep 17 00:00:00 2001 From: Zack T Date: Fri, 23 Mar 2018 13:39:07 -0700 Subject: [PATCH] v1.3 = Fixed a couple issues + Fixed a logic issue with where the curlAPI array is defined + Fixed an issue with a prinft statement that wasn't properly formed --- Jamf Pro/Admin Tools/jamf_CreatePrinters.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Jamf Pro/Admin Tools/jamf_CreatePrinters.sh b/Jamf Pro/Admin Tools/jamf_CreatePrinters.sh index e777553..24af935 100644 --- a/Jamf Pro/Admin Tools/jamf_CreatePrinters.sh +++ b/Jamf Pro/Admin Tools/jamf_CreatePrinters.sh @@ -3,7 +3,7 @@ ################################################################################################### # Script Name: jamf_CreatePrinters.sh # By: Zack Thompson / Created: 3/1/2018 -# Version: 1.2 / Updated: 3/23/2018 / By: ZT +# Version: 1.3 / Updated: 3/23/2018 / By: ZT # # Description: The purpose of this script is to assist Site Admins in creating Printers in Jamf without needing to use the Jamf Admin utility. # @@ -51,7 +51,7 @@ createPrinter() { fi # Get the Printer ID of the selected printer. - printerID=$(/usr/bin/printf $selectedPrinterName | cut -c 1) + printerID=$(/usr/bin/printf "${selectedPrinterName}" | cut -c 1) # Get only the selected printers info. selectedPrinterInfo=$(/usr/bin/printf '%s\n' "$printerInfo" | /usr/bin/xmllint --format - | /usr/bin/xpath "/printers/printer[$printerID]/display_name | /printers/printer[$printerID]/cups_name | /printers/printer[$printerID]/location | /printers/printer[$printerID]/device_uri | /printers/printer[$printerID]/model" 2>/dev/null | LANG=C /usr/bin/sed -e 's/<[^/>]*>//g' | LANG=C /usr/bin/sed -e 's/<[^>]*>/,/g') @@ -161,9 +161,6 @@ informBy() { createdByUser="${3}" jamfAPIUser=$(DecryptString $5 'Salt' 'Passphrase') jamfAPIPassword=$(DecryptString $6 'Salt' 'Passphrase') - - # Add -k (--insecure) to disable SSL verification - curlAPI=(--silent --show-error --fail --user "${jamfAPIUser}:${jamfAPIPassword}" --write-out "statusCode:%{http_code}" --output - --header "Content-Type: application/xml" --request) else action="${1}" ranBy="CLI" @@ -180,6 +177,9 @@ informBy() { jamfAPIPassword=$(/usr/bin/osascript -e 'set userInput to the text returned of (display dialog "Enter your Jamf Password:" default answer "" with hidden answer)' 2>/dev/null) fi + # Define the curl switches. Add -k (--insecure) to disable SSL verification. + curlAPI=(--silent --show-error --fail --user "${jamfAPIUser}:${jamfAPIPassword}" --write-out "statusCode:%{http_code}" --output - --header "Content-Type: application/xml" --request) + # Verify credentials were provided. if [[ -z "${jamfAPIUser}" && -z "${jamfAPIPassword}" ]]; then informBy "Jamf credentials are required!"