Posted on 09-07-2022 10:36 AM
Hi gang,
I'm trying to accomplish two things with Self Service. One policy will open Google Drive (this I have working in my script) followed by launching the location in a new Finder window upon clicking (ie: //Users/$loggedInUser/Google\ Drive/Shared\ drives/) for when people tell me "they lost their Google Drive." This new finder window is the piece that is not working. My error says location does not exist even though it does. So sounds like a permissions error?
For my next trick I want to have a policy that opens a PDF file stored on a shared Google Drive.
I have tried lots of ways to script this which all work locally for me fine but not when calling the policy through JAMF. I'm thinking permissions here too. Maybe a PPPC that I need to allowed Files and Folders access to JAMF or something else?
Thanks!
Solved! Go to Solution.
09-07-2022 11:41 AM - edited 09-07-2022 11:52 AM
I just tested this and it works for me without the use of a local user account:
#!/bin/bash
#Change Directory to Google Drive Share
cd "/Volumes/GoogleDrive/Shared drives/YourSharedDriveHere"
#Open current directory. New Finder Window by default
open .
You could add another line after opening the folder to open a file
#Open specified file using default application for file extension.
open "/Volumes/GoogleDrive/Shared drives/YourSharedDriveHere/yourfilehere.pdf"
#Open specified file using specific application
open -a "Preview" "/Volumes/GoogleDrive/Shared drives/YourSharedDriveHere/yourfilehere.pdf"
If you want to user the logged in user, this may work but ours isn't installed that way so I can't really test to be sure:
#!/bin/bash
#Get logged in user
consoleuser=$(stat -f "%Su" /dev/console)
echo "User is $consoleuser"
cd "/Users/$consoleuser/GoogleDrive/Shared drives/YourSharedDriveHere"
open .
09-07-2022 11:41 AM - edited 09-07-2022 11:52 AM
I just tested this and it works for me without the use of a local user account:
#!/bin/bash
#Change Directory to Google Drive Share
cd "/Volumes/GoogleDrive/Shared drives/YourSharedDriveHere"
#Open current directory. New Finder Window by default
open .
You could add another line after opening the folder to open a file
#Open specified file using default application for file extension.
open "/Volumes/GoogleDrive/Shared drives/YourSharedDriveHere/yourfilehere.pdf"
#Open specified file using specific application
open -a "Preview" "/Volumes/GoogleDrive/Shared drives/YourSharedDriveHere/yourfilehere.pdf"
If you want to user the logged in user, this may work but ours isn't installed that way so I can't really test to be sure:
#!/bin/bash
#Get logged in user
consoleuser=$(stat -f "%Su" /dev/console)
echo "User is $consoleuser"
cd "/Users/$consoleuser/GoogleDrive/Shared drives/YourSharedDriveHere"
open .
Posted on 09-07-2022 11:46 AM
Thank you @byrnese for the fast reply, I will give these a whirl and report back
Posted on 09-07-2022 12:43 PM
Thanks again @byrnese the top 2 scripts you provided worked perfectly after a little tinkering to my file locations. I didn't try the 3rd one with the logged in user. Guess I was just overthinking this and should've kept it simple instead of being cute from the beginning. Nice to know a PPPC is unnecessary for this. Cheers!
Posted on 09-07-2022 02:09 PM
Thank you for following up and marking it solved. I like to help people when I can :)
Posted on 02-28-2023 07:41 PM
Enough news and reviews, more stuff like this! My Ascension Login