Posted on 06-19-2022 02:08 PM
Hey everyone - I'm very much a beginner when it comes to coding and I'm very confused as to how to utilise any that people have posted as answers to questions in Github? Most of the time someone posts a comment that has a nice script in it, but if I copy and paste that script into a notepad, save it as a .bash - do I still need to chmod it? Does doing that do something to the file itself? Previously I just pasted the code into a notepad ++, did an EOL conversion to mac and saved it but it still failed to run as a script in JAMF. Wondering if I still need to chmod the file?
Solved! Go to Solution.
Posted on 06-19-2022 10:41 PM
Hello JAMFNoob,
Here are the steps you can follow to run those scripts locally on Mac (assuming you want to run it on Mac)
Hope this will help.
Regards,
Sam
Posted on 06-19-2022 10:41 PM
Hello JAMFNoob,
Here are the steps you can follow to run those scripts locally on Mac (assuming you want to run it on Mac)
Hope this will help.
Regards,
Sam
06-21-2022 01:53 AM - edited 06-21-2022 09:20 PM
@Samstar777 wrote: liteblueHello JAMFNoob,
Here are the steps you can follow to run those scripts locally on Mac (assuming you want to run it on Mac)
- it is always recommend to have a good tool, I prefer BBEdit
- Copy the script content from GitHub
- Paste it in BBEdit or TextEdit (native Mac app)
- save the file with extension .sh on ~/Desktop (this will save on desktop) or any other location on your Mac
- go to terminal
- run chmod +x /path/of/file (This will give executive permission to your script)
- run sudo sh /path/to/file (when you use sudo in terminal, make sure you have administrative account in Mac)
- Enter Password and see the results
Hope this will help.
Regards,
Sam
I appreciate the information and advice you have shared. I will try to figure it out for more.
Posted on 06-21-2022 07:06 AM
Just a few pieces of information.
First, I definitely also recommend you get yourself a decent coding/script writing application, like BBEdit or Visual Studio Code. Writing and editing scripts in TextEdit is not recommended as it often messes up the formatting and will make the script fail if that happens.
Second, when using most applications mentioned above, especially BBEdit, it's not usually necessary to do the chmod +x against the script to make it executable. The app will usually do that for you, but it's still a good thing to know how to do since there may be times you run across a script in some other way and will need to set the executable bit on it.
Lastly, if you feel confident that a script will be good as is, and don't need to test it locally first, you can always go into Jamf Pro, create a new script and copy/paste the contents directly into the window and save. Testing locally is still a good idea though, so I'm not saying you should always do this, at least not until you get good at reading scripts and understand everything that's going on in them.