Help detecting USB Drive


I was trying to use the following script to determine if a USB has been found or not, but it either doesn't have permission to check the /Volumes/ folder or doesn't work like that. Any help is apprecaited.

while [ ! -d "/Volumes/Summer 2021/" ] do echo "USB Not found. Waiting 30 seconds." if [ $Popups = true ] then osascript -e 'display notification "USB Missing!" with title "Automated Setup"' fi sleep 30 done

Legendary Contributor III

You have some mixed up combinations happening in that first line. Either use double quotes around the entire volume path (my preference) or use the character to escape spaces. You can't have both or it won't detect the volume in question.

Additionally, you're using osascript for the pop up dialog, which doesn't always work in the context of a script being run by Jamf as root. You may want to utilize one of the dialoging tools Jamf provides, like jamfHelper or the jamf binary's displayMessage syntax. Unless you have to capture some user input. In that case, you'd have to use osascript or something else since the Jamf tools don't provide that kind of interface. From your script though it looks like you're just popping up a simple message, so I'd probably use jamfHelper instead.