Skip to main content
Solved

Running "open" command in script while suppressing Terminal launch


Forum|alt.badge.img+6

We are deploying some software that prompts for local admin credentials when executed, which is problematic as most of our users have Standard accounts. I wrote up these couple of lines in bash:

#!/bin/bash
#Runs $PROGRAM as localadmin admin account to avoid requiring admin rights
sudo -u localadmin open /Applications/Utilities/PROGRAM.app/Contents/MacOS/PROGRAM_BINARY 
exit 0

and made it a policy available in Self-Service. This works, in that the program does the needful even if the user has a Standard account, however, the Terminal app launches as well, and does not go away after the software is done doing what it needs to do.

Is there a way to use the "open" command in a way that doesn't open Terminal? Or another way to execute an application as local admin?

Thanks,

-Mike

Best answer by mm2270

Have you tried just opening it at the app bundle level instead of the executable? I think the reason for the Terminal launching is because you're calling the executable inside the MacOS folder. Try just opening the app, meaning

sudo -u localadmin open /Applications/Utilities/PROGRAM.app

And you probably also don't need the sudo there since it will be running as root by default when run from a jamf policy.

View original
Did this topic help you find an answer to your question?

4 replies

Forum|alt.badge.img+9
  • Contributor
  • 149 replies
  • April 26, 2018

Have you tried entering the command in the "Files and Processes" -> Execute Command section instead of deploying a script?

We are doing this exact thing for a program called Provar that needs to run as admin once to enable git integration.


Forum|alt.badge.img+6

Yep, I tried it now, and it still launches Terminal like before. The interesting thing I noticed too, is that if I close Terminal, it terminates the software app since it seems to "own" the process.

-Mike


mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • Answer
  • April 26, 2018

Have you tried just opening it at the app bundle level instead of the executable? I think the reason for the Terminal launching is because you're calling the executable inside the MacOS folder. Try just opening the app, meaning

sudo -u localadmin open /Applications/Utilities/PROGRAM.app

And you probably also don't need the sudo there since it will be running as root by default when run from a jamf policy.


Forum|alt.badge.img+6

@mm2270 Thanks, that worked!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings