Skip to main content
Solved

Scripting help


Forum|alt.badge.img+5

We are pretty new to Jamf and still trying to understand the scripting.  We have a renamecomputer script that we got as part of our onboarding for computers.  Was working great till we started sending in the department on the user from Okta.  So now the naming is off.  I am pretty good at Powershell and C#, but bash scripts I am struggling with.  Is there way in a bash script to look up a department value in like a switch statement?

example if the department is "IT", then can you do something like this?

switch (department)

case "irs":

     value = 123

case "IT":

     value = 987

Any help or pointers to reference links would be great.  I am not sure what the bash term would be to do that so if I can get someone to help with that, might be able to get this figured out.

Best answer by mm2270

BTW, there is in fact such a thing in bash/zsh as a case statement, similar to what you posted above.

Example:

department="somevalue" case "$department" in irs) value="123" ;; IT) value="987" ;; esac

 You can add as many of these to the case statement as you need to.

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

5 replies

mm2270
Forum|alt.badge.img+16
  • Legendary Contributor
  • 7880 replies
  • April 9, 2024

Hi there! It might help us if you posted the existing script you're using right now, just for reference.

I guess I'm not quite understanding how including department information from Okta is causing the rename script to not work as expected, but that could be because I don't use Okta, so I'm not that familiar with it.


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

BTW, there is in fact such a thing in bash/zsh as a case statement, similar to what you posted above.

Example:

department="somevalue" case "$department" in irs) value="123" ;; IT) value="987" ;; esac

 You can add as many of these to the case statement as you need to.


Forum|alt.badge.img+5
  • Author
  • New Contributor
  • 3 replies
  • April 10, 2024
mm2270 wrote:

Hi there! It might help us if you posted the existing script you're using right now, just for reference.

I guess I'm not quite understanding how including department information from Okta is causing the rename script to not work as expected, but that could be because I don't use Okta, so I'm not that familiar with it.


 

*Removed


Forum|alt.badge.img+5
  • Author
  • New Contributor
  • 3 replies
  • April 10, 2024
mm2270 wrote:

BTW, there is in fact such a thing in bash/zsh as a case statement, similar to what you posted above.

Example:

department="somevalue" case "$department" in irs) value="123" ;; IT) value="987" ;; esac

 You can add as many of these to the case statement as you need to.


That is exactly what I was looking for.  Thank you!


Forum|alt.badge.img+5
  • New Contributor
  • 34 replies
  • April 10, 2024
mlinkey wrote:

 

*Removed


Just sent you a PM - not sure if you have notifications set up, so posting a message here too


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