Opening and closing System Prefpanes with command line actions in a shell script
I am trying to automate a process for my wife and my daughter to backup their Time Capsules (5th Gen, Seagate drives) to an external hard disk *before* the TC disk dies (mine died recently after about 4 years of normal use).
Carbon Copy Cloner 5, which I have decided to use, can run preprocess and postprocess bash scripts.
The process I want to automate is:
WHEN MacBook is present and connected to Time Capsule AND external hard disk
then as CCC preprocess script
open Time Machine Preferences (to show progress)
backup MacBook (to Time Capsule) and wait for finish [tmutil startbackup -b]
close Time Machine Preferences
let CCC run and backup
in postprocess script, send an iMessage to one or the other iPhone.
CCC handles the Time Machine and external disk both present check.
in the preprocess script I can open and display Time Machine Preferences with
open -b com.apple.systempreferences /System/Library/PreferencePanes/TimeMachine.prefPane
MY QUESTION:
but HOW DO I CLOSE the PrefPane (its been a while, as an 80-year old, that I did any serious Mac programming)
for the postprocess script to send iMessage to phone, I have been able to steal some scripts from the Web.
Any help on closing Time Machine Preferences in a shell script would be appreciated
Trevor
MacBook Air 13″, macOS 10.13