Skip to main content
Solved

Run Jamf CLI commands inside a bash script


Forum|alt.badge.img+3

Hello folks,

 

any chance to run Jamf CLI commands like "sudo jamf policy" or "sudo jamf launchSelfService" from a bash script?

 

Thanks a lot|

Best answer by PaulHazelden

Try using the fullpath for jamf

/usr/local/bin/jamf
I have found some scripts fail until I use the full path to the command.

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

6 replies

sdagley
Forum|alt.badge.img+25
  • Jamf Heroes
  • 3532 replies
  • March 26, 2022

@BusterCasey Run your script via sudo (e.g. sudo ./myscript.sh) and in the script don't prefix the jamf binary cals with a sudo (i.e. use 'jamf policy' instead of 'sudo jamf policy')


Forum|alt.badge.img+3
  • Author
  • New Contributor
  • 2 replies
  • March 26, 2022
sdagley wrote:

@BusterCasey Run your script via sudo (e.g. sudo ./myscript.sh) and in the script don't prefix the jamf binary cals with a sudo (i.e. use 'jamf policy' instead of 'sudo jamf policy')


Thank you, It works. I realized that the issue is that i launch the bash script from a Applescript:

do shell script "/path/to/yourscript.sh" with administrator privileges

Every bash commands inside the sh works great (sudo or not) except the jamf cals to the jamf binary. Can't understand why ðŸ˜¥


PaulHazelden
Forum|alt.badge.img+12
  • Jamf Heroes
  • 375 replies
  • Answer
  • March 28, 2022

Try using the fullpath for jamf

/usr/local/bin/jamf
I have found some scripts fail until I use the full path to the command.


Forum|alt.badge.img+8
  • Valued Contributor
  • 50 replies
  • March 28, 2022

I Set a policy up in self service to be able to run what I call a check in.

 

 

#!/bin/bash sudo jamf policy; sudo jamf recon

 

 

 

Even gave it an icon.  That way I can scope something out and tell a user to go to self service and check in so we don't have to wait..


Forum|alt.badge.img+14
  • Contributor
  • 29 replies
  • March 28, 2022

User the full path: /usr/local/bin/jamf

I have to do this with commands in Apple Remote Desktop


PaulHazelden
Forum|alt.badge.img+12
  • Jamf Heroes
  • 375 replies
  • March 29, 2022
BoscoATX wrote:

User the full path: /usr/local/bin/jamf

I have to do this with commands in Apple Remote Desktop


The easy way to find the full path for any command is to use the which command in terminal,
so 
which jamf
Returns
/usr/local/bin/jamf


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