Simple Bash script

AppleCom
New Contributor

I have a configuration profile that adds our VPN configuration. I then have a policy that kicks off this simple bash script. 

open “/System/Library/CoreServices/Menu Extras/vpn.menu” 

All this does is check the box for "Show VPN status in the menu bar"

This is the error that I'm getting.

Script result: The files /“/System/Library/CoreServices/Menu and /Extras/vpn.menu” do not exist. 

When I run the command in the terminal it completes successfully.

1 ACCEPTED SOLUTION

sdagley
Esteemed Contributor II

Did you really use “ (curly double quotes) instead of " (straight double quotes)? If so change them all to straight quotes.

View solution in original post

5 REPLIES 5

AJPinto
Honored Contributor II

On my device I can't even run that command in terminal, I get "The files /Users/UserID/“/System/Library/CoreServices/Menu and /Users/UserID/Extras/vpn.menu” do not exist." I believe core services is a symbolic link directory, you will need to locate the original path. 

 

lrwxr-xr-x   1 root  wheel       90 Feb  2 11:19 coreservicesd -> ../Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Support/coreservicesd

sdagley
Esteemed Contributor II

Did you really use “ (curly double quotes) instead of " (straight double quotes)? If so change them all to straight quotes.

That was it. Thank you.

howie_isaacks
Valued Contributor II

I write all of my scripts in BBEdit and sometimes in CodeRunner. I actually never gave this any thought... curly vs. straight quotes. I figured the style of the quotes was controlled by the font they're typed in.

talkingmoose
Moderator
Moderator

I think the problem is that you're trying to run something by command line that opens an app. Jamf Pro runs commands as root, which means you're trying to open the app as root. But root isn't logged in.

Add a couple lines to the beginning to get the current user. Then use sudo or su to run the open command as that user.