Current network domain using AS / ASOC

I’m using "ipconfig getpacket en0 ;ipconfig getpacket en1 " to find the current domain of the machine. The interesting line is:

domain_name (string): acme.com

Works fine in bash, but returns (error 1) (despite actually working and bringing back the results)

I’d much rather do something more elegant. I’ve had a look in the “System Events” dictionary but the only mention of domain is all about user and system folders

I could, of course, use “scutil --dns” which also brings back the current host

However, I’d like to avoid bash if possible

Have you looked at NSHost?

Well, that was easier than expected! Cheers Shane:

use framework "Foundation"
set theHostNames to current application's NSHost's currentHost's names as list
set theHostAddresses to current application's NSHost's currentHost's addresses as list

log theHostNames
log theHostAddresses

Anything to avoid bash :wink: