Re-running a Unix command, until it completes successfully – e.g.: imapsync

I’m doing an email migration for a client from an old 2008 SBS Server into Office 365. For some reason, there were two mailboxes that just wouldn’t migrate using the migration wizard in Office 365.

I switched to the ever-trusty imapsync which I’ve used to migrate more mailboxes than I care to remember.

As an aside, I had a few issues with imapsync from MacPorts so ended up downloading a fork from GitHub that resolved the issue, however I had to install a few CPAN modules for Perl manually. I’ve lost the link to the GitHib version, however it was easy to find initially by searching on the error string that it was returning when trying to run it – something about an SSL error.

Anyway, after building and installing everything required, imapsync kept erroring out on these two mailboxes after some random number of emails migrated. After logging in and restarting it manually a few times, I thought that there had to be a better way.

Looking further into the issues, imapsync was exiting with a return code of 2, indicating that an error occurred. When it completes successfully, it should exit with a return code of 0. This makes it easy to just keep running it until it exits with zero;

until imapsync --option1 --option2 ... --optionn; do
    echo Exited with an error, rerunning...

Nice and easy…

The until loop keeps running the command given to until (often a check for something == 0) exits with a true (or zero) exit status. The echo statement gets executed as part of the until loop, however this is more a side effect of running imapsync as the until loop predicate.


Sonos and Spotify

I make no secret of it, I love Sonos gear and am thoroughly addicted to it. It started out quite innocently with just a single PLAY:1 that was soon joined by it’s twin to make a stereo pair – these live in my bedroom and work as the best alarm clock I’ve ever used. Not long after that a PLAY:3 joined the mix in the living room, and then as it was lonely on it’s own, a second one came along… And, well, you get the idea.

One of the best features of Sonos is it’s integration with 3rd party streaming music services. As well as being able to play from your iTunes music library, either stored directly on your computer, or accessed via a NAS or a home server, you can play from a huge number of streaming radio stations as well as services like Pandora, SoundCloud and Spotify.

I have been listening to the high quality music that the folks over at SomaFM have been broadcasting for more than a decade now – they have expanded the number of stations that they broadcast over the years however the sounds on Groove Salad, Beat Blender and Lush have consistently been in my playlists for a long time.

Sometimes however you want to listen to something more specific and this is where Spotify shines. Whilst you have been able to listen to Spotify streams in Sonos for some time now, the integration has always seemed like a bit of an afterthought. I’m sure that this was partly for technical reasons and partly for legal or political reasons, but whatever the reason, it was never as straightforward as it should have been.

If you wanted to listen to a particular album or stream on Spotify, you first had to go into the Spotify app or web app, find what you wanted to listen to, save it as a Playlist or a Favourite and then go into the Sonos app and locate it from there.

With the latest Sonos update, this has all changed. Version 5.5 brings to the table the ability to start a new Sonos station from the song that’s currently playing, or search for your favourite artist – all within the Sonos app. They also deliver a Daily Soundtrack with a selection of playlists based on the current time of day (it’s 7am and I’m presented with a Rise and Shine! selection). You can also browse Genres and Moods, New Releases and Charts – pretty much the entire experience you get when using the Spotify app itself.

All in all, this is a highly recommended update if you’ve got Sonos and Spotify, and it’s free – so get onto it!

OS X 10.11 El Capitan and System Integrity Protection (SIP)

This is shamelessly cut and pasted from TwoCanoes:

System Integrity Protection (SIP)

Apple has implemented a new security feature in OS X 10.11, System Integrity Protection, which prevents even super users from altering the contents of files in key System folders. The flags for restricting the folders is applied at the time of installation and cannot be overridden. SIP is designed to protect System files from malware and viruses.

For the specific cases described above, SIP must be disabled to allow writing to the master boot record when restoring a Winclone image. After the restore process is complete, SIP may be enabled again from the Recovery partition.

Disabling SIP requires booting into the recovery partition to run the Terminal command below.  

To boot into the Recovery partition, hold Command-R while restarting the Mac.  

From the Utilities Menu, select Terminal.  On the Terminal command line, enter:

# csrutil disable

which will confirm the change with status message:

Successfully disabled System Integrity Protection. Please restart the machine for the changes to take effect.

Reboot back into the El Capitan system partition.

To re-enable SIP, boot back into the recovery partition, open Terminal from the Utilities menu and set state to enabled:

# csrutil enable

Product Review: Overboard Waterproof eBook Reader / Kindle Case

This is a pretty simple case, it does one thing and it does that one thing quite well.

Unlike just about all other kindle accessories, the Overboard Waterproof eBook Reader / Kindle Case is a more universal accessory and will fit any number of different devices – from a Kindle to an iPad mini or any other device with a screen size less than 8-9 inches or so.

It accomplishes this by being a tough, flexible waterproof and air-tight bag with an easy sealing mechanism at the top.

You unlock the four locks in the thick plastic seal, open the bag, drop your device in, with the screen towards the clear side and then seal it all up. The case is supplied with a shoulder carry strap (that I thought was cute but really am probably not going to use) and a few small sachets of Silica Gel – those little white sachets that say DO NOT EAT that are invariably packed in with your new electronics. Silica Gel will absorb moisture, and it does it very well. Overboard were thoughtful enough to supply these sachets sealed in a ziplock bag, so they haven’t already absorbed all the moisture they can out of the air before you go to use them.

Why would you need to use them? Well, this case (bag?) is pretty well waterproof.

Ever wanted to read your Kindle in the bath, or at the beach and don’t want to get it sandy or wet? This is the answer to that problem!

If you’re using the case in a humid environment, you can put a silica gel sachet in with your device, and then you’re not going to get any fogging inside the bag.

In my testing, this case worked exactly as promised – my kindle is none the worse for wear after being read in the bath, washed under the tap and taken into the shower just to see how it went.

The clear front surface of the case is a tough and flexible plastic that doesn’t seem to interfere with the touch screen on either my kindle or iPhone (I don’t have an iPad mini to test it with).

All in all, a handy thing to have if you’re holidaying with your Kindle, or want to use it in the bath…

Fix NTP on OS X with no external network access

NTP is built into all recent versions of OS X and OS X Server (and OS X with

If you’re running a server, the other clients on the network can receive time updates from the server – but only if the server is able to update it’s time to an authoritative time server on the internet or other network.

If, as I was confronted with recently, you have a server and UDP Port 123 is blocked, then the server is unable to sync it’s time with any more authoritative time servers. If the server is unable to sync it’s clock, by default it refuses to give out time updates to network clients. How annoying.

With OpenDirectory, and it’s use of Kerberos, if workstations drift more than a few minutes from the server, bad things happen.

In this case, it is desirable to have all workstations sync their time to the server. Even if the time on the server isn’t completely accurate, it’s still better that all computers on the network at least agree what they think the time is, rather than having them all showing different times.

In order to do this, the NTP service running on the server must be told it’s a stratum time server. With stratum time servers, they’re authoritative with respect to what time it is. Normally, they’re connected to a highly accurate atomic clock or get an accurate time from GPS signals.

To tell our OS X server that it’s a stratum time server, edit /etc/ntp.conf and put in the following two lines. Note that is not a typo, it’s not meant to be

server # local clock
fudge stratum 10

This then tells the ntpd service on the server that it’s a Stratum 10 time server. Lower stratum numbers are higher priority and higher accuracy servers, so saying we’re at Stratum 10 means that if we do end up talking to real ntp server, it will be a lower stratum (and therefore higher priority) to our local clock.

Restart the ntp service with sudo killall -HUP ntpd

Point the network clients to the server and in very short order, they should have their clocks synchronised.


Bypass Spam Filtering in Office 365

This one is quick and easy – how do you whitelist a domain to bypass spam filtering in Office 365?

Log into the admin console at

Go to ADMIN > Exchange

In the Exchange admin centre, go to mail flow > rules

From the + dropdown menu go down to Bypass spam filtering…

Give the rule a name (e.g. Whitelist domains or bypass spam filtering)

From Apply this rule if… select The sender… > domain is and enter the domain (e.g. – don’t forget to hit the + button before you click on the OK button.

Leave the rest of the rule as-is and hit the Save button.

Getting a Fluke CableIQ to work in VMware Fusion on Mac OS X

I just got a new Fluke CableIQ qualification tester and, of course, the software and all supporting materials are Windows only.
I’m currently running Windows 7, 8 & 10 in VMware Fusion – yet Fusion wouldn’t see the USB device to attach.
It did give me a very metaphysical message on the LCD of the CableIQ however – The PC is searching within itself for the driver…

Anyway, in Fusion, you can enable USB quirks to fix recalcitrant USB devices and this is exactly what I needed to do to fix it.

From the VMware Knowledge Base article:

All I had to do was edit my .vmx file and add the following line to the bottom:

usb.quirks.device0 = "0x0f7e:0x0003 skip-reset"

I go the Vendor ID of 0x0f7e and the Product ID of 0x0003 from the vmware.log file in the Virtual Machine bundle folder.

Product Review – Encase Folding Stand Case

I’ll keep this short and sweet – the Encase Folding Stand Case is a very nice case for an iPad.
It’s thin and lightweight and more versatile than Apple’s Smart Case. Due to the unique triangular folds for the cover, it’s significantly more stable when propped up on a desk, or even on your lap.
It’s available in a wide range of colours and it’s made very well.
All-in-all, it gets the thumbs up if you need a good alternative to Apple’s case – one that retains the benefits of the OEM case and adds better features.

I’ve given this case to a friend and they really like it – it’s a lot slimmer and more lightweight than many other cases on the market.

The iPad is really a lot better supported when you have it resting against the folded case and the case can support the iPad in both landscape and portrait orientation, whereas most other cases only support the iPad in landscape mode.