The Jamf Pro web interface includes a built-in script editor which allows you to make changes to existing scripts, or to compose new scripts entirely within the Jamf Pro interface. There is one gotcha with this editor that is not really Jamf's fault, and one that experienced programmers can probably see coming: when working with Python scripts, you need to be sure to use consistent indentation, or else you'll see policy failures with errors indicating so.
What happens, at least in my case, is that I will write a Python script in Notepad++, nano, or some other editor that I have set up to replace tab characters with spaces, then copy-and-paste that script into the Jamf Pro web interface. Then, later on, when I go to edit the script, I'll hit the tab key, and the editor dutifully inserts a tab character. This confuses Python, which uses differing levels of indentation to determine code blocks (versus C-style languages, which use curly brackets).
When this happens, you can manually correct the indentation by replacing tabs with spaces, or you can copy-and-paste the indentation from another line at the same level. Another way to get around this, of course, is to copy the script from the Jamf Pro interface into your text editor of choice, make your changes, then copy it back into Jamf Pro, which avoids this issue, but adds some extra work.
This isn't a problem with bash or other scripting languages, as these aren't so strongly influenced by indentation. This also isn't fundamentally a problem with the Jamf Pro script editor, which inserts the character that you're asking it for, but more of a problem with muscle memory working against you when moving between two editors that are not set up in exactly the same way.
Friday, May 10, 2019
Saturday, May 4, 2019
Built-in Unix tools on Windows 10
As you may be aware, Windows 10 supports running a full Linux/bash environment via the Windows Subsystem for Linux (WSL). This can be installed from the Windows Store, or via PowerShell, and gives you access to the tools provided by your chosen distribution without the need to reboot or start up a VM.
However, Windows 10 also (as of April 2018) includes a few very useful tools without even needing to enable the WSL. These tools are:
However, Windows 10 also (as of April 2018) includes a few very useful tools without even needing to enable the WSL. These tools are:
- ssh - "Secure SHell", allowing you to access Linux, Unix, macOS, and other related operating systems remotely from the command line
- curl - "Client URL", which you can use to upload/download files and make requests to web servers from the command line
- tar - "Tape ARchive", which allows you to combine many files into one archive for ease of transport and/or compression
These tools are now included and enabled by default in Windows 10, and can be accessed from either cmd.exe or PowerShell. One difference between these two shells is in the curl command: in cmd.exe, this runs as a regular executable, with the same flags that you would expect on a Unix machine; however, in PowerShell, curl is an alias to the Invoke-WebRequest cmdlet, so its arguments are not the same. You can get around this by specifying curl.exe in PowerShell to get the standard behavior.
These tools, ssh in particular, are very useful in my daily work as they allow me to remote into Macs without needing to have PuTTY or some other terminal installed. tar is also useful because it helps reduce the slowness you may encounter when copying many small files; by combining these files into one larger archive, you can avoid the time overhead required to start and stop the copying operation for each, only paying that time penalty once.
These tools are also useful for scripting, even (or especially) in batch files. PowerShell provides cmdlets that replicate the functionality of curl, for example, but now that it's included by default, you can easily write a plain old .bat file to download a file from a website, or even to make a HTTP request to a server by POSTing to a URL.
Subscribe to:
Posts (Atom)
Tableau, TabPy, and the Case of No Input Rows
I haven't scientifically confirmed this or anything, but it sure seems like if you pass an empty dataframe to a TabPy script, then no m...
-
Configuration Profiles are Apple's somewhat newer, MDM-esque management solution for Macs, similar to how iPads and iPhones are managed....
-
Among other applications, we deploy Apple's GarageBand using Munki. GarageBand can be installed without too much trouble, but on first ...
-
I recently had cause to install an old piece of software on 20 computers in a lab, and was looking for a way to automate this installation t...