Scripting help

mlinkey
New Contributor

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.

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

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 solution in original post

5 REPLIES 5

mm2270
Legendary Contributor III

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.

mlinkey
New Contributor

 

*Removed

wkelly1
New Contributor III

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

mm2270
Legendary Contributor III

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.

mlinkey
New Contributor

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