• cloud,  Mac OS X,  Ubuntu,  Unix

    Scripting Instances On Google Cloud From A Mac

    Over the users I’ve written a good bit about pushing a workload off to a virtual machine sitting in a data center somewhere. The Google CloudPlatform has matured a lot and I haven’t really gotten around to writing about it. So… It’s worth going into their SDK and what it looks like from a shell using some quick examples. For starters, you’ll need an account with Google Cloud Platform, at cloud.google.com and you’ll want to go ahead and login to the interface, which is pretty self-explanatory (although at first you might have to hunt a little for some of the more finely grained features, like zoning virtual instances. The SDK…

  • Mac OS X,  Mac OS X Server,  Mac Security,  Ubuntu,  Unix

    To Hex And Back

    The xxd is a bash command in Linux and macOS that is used to take a hexdump (convert a string to hex), or convert hex back to a string. To use xxd, just call it with a couple of options. Below, we’ll use the -p option to export into plain hexdump, and we’ll quote it and the <<< is to take input rather than a file name to convert (the default behavior), as follows: xxd -p <<< "hey it's a string" The output would be a hex string, as follows: 6865792069742773206120737472696e670a Then use the -r option to revert your hex back to text. Since xxd doesn’t allow for a positional…

  • bash,  Mac OS X,  Mac OS X Server,  Mac Security,  Ubuntu

    Programmatically Grab Active DNS Servers On macOS

    One of my favorite things about grabbing things with scripts is just how many ways (and sometimes how needfully or needlessly convoluted you can make them) to grab the same pieces of information. For example, something as simple as what hosts you use to resolve names on a Mac. There are a number of ways to grab what DNS server a device is using in macOS. So when you’re running a script you might choose to grab DNS information one way or another, according to what you’re after. Some of this might seem more complicated than it should be. And that’s correct… resolv.conf The /etc/resolv.conf file is updated automatically to…

  • Programming,  Ubuntu

    Check Your Bash Scripts For Syntax

    There’s a great site out there called spellcheck.net that will check your bash scripts to verify that they are syntactically correct and offer some tips on fixing issues you may encounter. In the example below, I single quoted at the end of a quoted string, and… error Hat tip to Daniel MacLaughlin for posting this site.

  • Mac OS X,  Mac OS X Server,  Ubuntu

    Simple XPath options with Jamf Pro

    Given the increased reliance on XML in scripts and exchanging data, a number of different solutions leverage XML traversal options to get all the things done. We frequently use path to bring a file into a script or program, or accept input from STDIN. The most basic task that we then perform is simply selecting an item from that file or STDIN and then variabalizing it. One common tool that we use here is Path. XPath calls these objects nodes, and uses path expressions to select these nodes. A path expression is the path along the xml input that is followed to find a piece of data. There are some…

  • Mac OS X,  Mac OS X Server,  Mac Security,  Ubuntu,  Unix

    Run a script directly from github

    There are a lot of scripts stored on github. And you can run them directly by curling them into bash. To do so, you’ll need a link to the raw script (using the github page with the URL of the script brings in all the cruft, so you’ll need to find the raw text). To grab that, click on the page with the script and then right-click  on Raw, as seen here: Then, throw out a bash command followed by < and then the URL you just copied into your clipboard in parenthesis: bash <(curl -Ls https://github.com/krypted/resetsoftwareupdate/raw/master/resetsoftwareupdate.sh)

  • ChromeOS,  Ubuntu,  Unix

    Make Changes to the Chromium rootfs

    By default, the Chromium OS rootfs is read-only. If you boot the system in developer mode, you will be able to disable rootfs verification and modify existing files or write new files into the file system. Before you do this, note that your file system will no longer be verifiable (won’t checksum properly) and you’ll end up needing to restore a recovery image in order to get back to normal mode. So this might be a bit dangerous if you’re not using the device for something like regression analysis (why I needed to do this). To make the file system writeable, first fire up a command prompt via crosh, by using Control-Alt-T…

  • Mac OS X,  Mac OS X Server,  Mac Security,  Mass Deployment,  Ubuntu,  Unix

    Bash History Fun

    We tend to use a lot of commands in the Terminal app. That is, after all, what it’s there fore. And there’s a nice history of what we do. There are also a number of ways to view and manage the bash history. The simplest of which is the history command, which will show the previous commands run. Here, we’ll simply run it: history Keep in mind that this shows the history based on context, so if you sudo bash, you’ll potentially see a different history. You can also use the bash built-in fc command, which has the additional awesomeness of being able to edit and re-run commands from the…