After some hours of digging through the internet, it seems that the only way to put an airport in HostAP ("software base station") mode in OS X 10.8 Mountain Lion is to programatically call a the internal, undocumented, startHostAPModeWithSSID
method.
I've updated the one example I could find online, and it does seem to work, with the one caveat that only WEP, not WPA, can be used: https://gist.github.com/4418079
Wish I could claim credit for this one, but I found it buried in https://github.com/chcokr/osx-init/blob/master/install.sh
This worked on my 10.10 headless VM without a logged in UI. Updates applied for compatibility with at least 10.9-10.14
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress;
PROD=$(softwareupdate -l |
grep "\*.*Command Line" |
head -n 1 | awk -F"*" '{print $2}' |
sed -e 's/^ *//' |
tr -d '\n')
softwareupdate -i "$PROD" --verbose
rm /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
This presumes you only have 1 result to
softwareupdate -l | grep "\*.*Command Line"
- if this returns multiple versions, you might need more specific logic. (I dont have a repro case)
one variation that seems to work (limited testing) on 10.10-10.14 (10.9 doesn't return an osx version number in the cli tools name..so this doesn't work there):
PROD=$(softwareupdate -l |
grep "\*.*Command Line.*$(sw_vers -productVersion|awk -F. '{print $1"."$2}')" |
head -n 1 | awk -F"*" '{print $2}' |
sed -e 's/^ *//' |
tr -d '\n')
a few example results:
* Command Line Tools (OS X Mavericks)-6.2
* Command Line Tools (OS X 10.10) for Xcode-7.2
* Command Line Tools (macOS El Capitan version 10.11) for Xcode-8.2
* Command Line Tools (macOS High Sierra version 10.13) for Xcode-10.1
* Command Line Tools (macOS Mojave version 10.14) for Xcode-10.1
Best Answer
To open a standard macOS application bundle, e.g. Network Diagnostics.app, via the command line, in e.g. Terminal, you can use the
open
command with the-a
option, e.g.:Note that you do not necessarily need to use the
.app
extension or its pathname,/System/Library/CoreServices/Network Diagnostics.app
, although you can if you so choose or the situation warrants it.Note: In the use case there is no need or advantage to using the fully qualified pathname of the binary executable:
Aside from the fact it's not necessary because the
open -a
command is there for that, using just the fully qualified pathname of the binary executable from the command line forces Terminal to stay open and that window is unusable until finished and Terminal cannot be closed without also terminating the binary executable of Network Diagnostics in the case.Also note that even using an
&
after the fully qualified pathname, while it will return the command prompt, Terminal still cannot be closed without also terminating e.g. Network Diagnostics.This is why using the
open
command with the-a
option is the way to go when wanting to open a standard macOS application bundle from the command line.