Opening a Finder location & Google Drive PDF

mvpaa
New Contributor II

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!

1 ACCEPTED SOLUTION

byrnese
New Contributor III

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 .

 

 

View solution in original post

5 REPLIES 5

byrnese
New Contributor III

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 .

 

 

mvpaa
New Contributor II

Thank you @byrnese for the fast reply, I will give these a whirl and report back

mvpaa
New Contributor II

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!

byrnese
New Contributor III

Thank you for following up and marking it solved. I like to help people when I can :)

jems6957
New Contributor

Enough news and reviews, more stuff like this! My Ascension Login