Skip to main content
Question

Script to edit Hosts File

  • October 27, 2016
  • 1 reply
  • 0 views

Forum|alt.badge.img+1

Does anyone have a script to edit the Hosts file that they'd be willing to share? We need to add an entry to enforce Google Safe Search.

1 reply

Forum|alt.badge.img+7
  • Contributor
  • 94 replies
  • October 27, 2016

Here is part of an automator script I use to block a few sites:

do shell script "echo '#' > /private/etc/hosts" with administrator privileges do shell script "echo '#' Host Database >> /private/etc/hosts" with administrator privileges do shell script "echo '#' >> /private/etc/hosts" with administrator privileges do shell script "echo '#' localhost is used to configure the loopback interface >> /private/etc/hosts" with administrator privileges do shell script "echo '#' when the system is booting. Do not change this entry. >> /private/etc/hosts" with administrator privileges do shell script "echo '#' >> /private/etc/hosts" with administrator privileges do shell script "echo 127.0.0.1 localhost >> /private/etc/hosts" with administrator privileges do shell script "echo 255.255.255.255 broadcasthost >> /private/etc/hosts" with administrator privileges do shell script "echo ::1 localhost >> /private/etc/hosts" with administrator privileges do shell script "echo 127.0.0.1 itunes.apple.com >> /private/etc/hosts" with administrator privileges do shell script "echo 127.0.0.1 youtube.com >> /private/etc/hosts" with administrator privileges do shell script "echo 127.0.0.1 www.youtube.com >> /private/etc/hosts" with administrator privileges do shell script "echo 127.0.0.1 m.youtube.com >> /private/etc/hosts" with administrator privileges do shell script "killall -HUP mDNSResponder" with administrator privileges

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings