Skip to content

Instantly share code, notes, and snippets.

@jordansaints
Last active August 29, 2015 14:23
Show Gist options
  • Save jordansaints/4a7c80b9293f7d7312ac to your computer and use it in GitHub Desktop.
Save jordansaints/4a7c80b9293f7d7312ac to your computer and use it in GitHub Desktop.
OS X version-aware flushing of the DNS cache
-- OS X version-aware flushing of the DNS cache
-- Intended for use in an Alfred Flush-DNS workflow
set os_version to do shell script "sw_vers -productVersion"
if os_version ≥ "10.3" and os_version < "10.5" then
do shell script "lookupd -flushcache"
else if os_version < "10.7" then
do shell script "dscacheutil -flushcache"
else if os_version < "10.9" then
do shell script "killall -HUP mDNSResponder" with administrator privileges
else if os_version < "10.10" then
do shell script "dscacheutil -flushcache"
do shell script "killall -HUP mDNSResponder" with administrator privileges
else if os_version ≥ "10.10" and os_version < "10.11" then
do shell script "discoveryutil mdnsflushcache" with administrator privileges
do shell script "discoveryutil udnsflushcaches" with administrator privileges
else
display dialog "This version of OS X is not supported"
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment