Scripting Language preference

New Contributor III

In two weeks I am will be in the CCT course and I am currently getting my feet wet with Casper. I've spent many hours reading discussions here and i've come across a lot of different ways things can get done. I've seen BASH, Perl, Ruby, Python, and AppleScript. Is there really a preference for Casper or is there a "use what you are most comfortable with" mentality. I'm asking because i'd like to focus on one and hone my skills.

Thanks in advance.


Contributor III

Any scripting language that can run on the client device will work.

Bash is probably the most commonly used one.

But Python is more powerful and becoming more common amongst sys admins

If it was me, I'd be looking to learn Python

Contributor II

@rtrouton has a pretty good answer for this I think

The bit in question really would be "Use the right tool for the job you're working on"

Honored Contributor II
Honored Contributor II

I'd have to say bash and Python personally. Not sure if there is a clear winner and the "use the right one for the task" is very true. Python is definitely more powerful at some tasks, but bash has its uses for neat one liners.

New Contributor III

Thanks for the quick responses everyone.

Contributor III

I would add that focusing on learning the command line tools that will be called in these scripts is most important. If you learn about softwareupdate, csrutil, diskutil, hdiutil, systemsetup, networksetup, dscl, installer, grep, jamf binary, and a few others you will be able to design a script in any language to accomplish your goals.
Another thing to think about is when to script. Personally I am trying to reduce my dependency on scripting and look at what I can accomplish with "Execute Command" in the "Files and Processes" option of casper policies.
This helps with modularity and if you make use of Casper Sites.

Valued Contributor II

Shell/Bash and then a bit of Python. I am going to take a Python class at General Assembly here in Boston as it is most useful!

New Contributor III

Definitely use what fits the task, and your coding style the best. Bash is always good to have in your arsenal, and the code is more accessible to a wider audience, but others are more powerful.

I'm a rubyist myself, because it fits how I think more comfortably, but the equally-powerful python is more commonly used in the sysadmin world. Perl is still powerful, but unless you already know it, I'd go for ruby or python, both of which were developed (in part) to take the good parts of perl and address the not-so-good ones.

Some Applescript knowledge is also a good thing to have, because regardless of your primary language, there are some tasks that just work better with Applescript, and you can use osascript to execute Applescript snippets from any other language.

Valued Contributor III

I use bash for pretty much everything, but it's easy enough to use another language for certain things. For example, I needed SMTP to send email notifications in a bash script, and I echo out and run a python script from my bash script just for that function.