Announcement

Collapse
No announcement yet.

Script to automate building an adblocking hosts file

Collapse
This topic is closed.
X
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Ya, I'll get over it. Just a small case of brain envy!

    (I hadn't noticed that "two hour" thing last November...)
    "A nation that is afraid to let its people judge the truth and falsehood in an open market is a nation that is afraid of its people.”
    – John F. Kennedy, February 26, 1962.

    Comment


      #17
      Originally posted by GreyGeek View Post
      (I hadn't noticed that "two hour" thing last November...)
      Ah... I thought maybe you had meant to reply to some other thread here on the board!

      Comment


        #18
        Have you updated this one lately?

        GG's intergalactic hitchhiking not withstanding of course...

        ...don't forget your towel Jerry!

        Please Read Me

        Comment


          #19
          Nope. I plan to add the extra functionality discussed here: KDialog and an easy-on-off mechanism at least. A relatively simple tailoring mechanism like what you described earlier shouldn't be too difficult, either.

          Alas, it's easy to get distracted! I have some air travel coming up, and Alaska Air has wi-fi on all planes now, so perhaps I can put those five hours on SEA-DCA to good use, eh?

          Comment


            #20
            Just created SR's script and ran it and replaced my /etc/hosts file accordingly. Rebooted. Browsing does indeed seem more responsive - snappier. Cool.

            Note: I at least, could not execute the script by just typing gethosts. Kept getting "gethosts: command not found". Executing it with
            Code:
            ./gethosts
            works.
            Windows no longer obstructs my view.
            Using Kubuntu Linux since March 23, 2007.
            "It is a capital mistake to theorize before one has data." - Sherlock Holmes

            Comment


              #21
              What directory did you save the script in? Home, I'm guessing, and also guessing that's not in your PATH.

              If you put it in ~/bin it will get found. (After you start a new shell - one of the bash initialisation scripts add ~/bin to your path if it exists.)
              I'd rather be locked out than locked in.

              Comment


                #22
                Right... unlike Windows, which always checks the current subdirectory before following %PATH%, Linux only follows $PATH. So
                Code:
                ./gethosts
                would work if your current working directory is the one containing the script. Alternately, if your script is in your home directory,
                Code:
                ~/gethosts
                will execute the script regardless of what your current working directory is.

                Comment


                  #23
                  Originally posted by SteveRiley View Post
                  Windows, which always checks the current subdirectory before following %PATH%
                  Wait, that would be so convenient. Why doesn't Linux do that?

                  Oh, I remember. Security!
                  I'd rather be locked out than locked in.

                  Comment


                    #24
                    Originally posted by SteveRiley View Post
                    Save the text above into a file called ~/gethosts.
                    I followed Steve's instructions exactly as stated to above -- which saves the file in the users home directory.
                    Windows no longer obstructs my view.
                    Using Kubuntu Linux since March 23, 2007.
                    "It is a capital mistake to theorize before one has data." - Sherlock Holmes

                    Comment


                      #25
                      Oh indeed. I'm not suggesting you did something wrong. I'm suggesting a slight improvement to Steve's instructions. ...
                      I'd rather be locked out than locked in.

                      Comment


                        #26
                        Originally posted by SecretCode View Post
                        Oh indeed. I'm not suggesting you did something wrong. I'm suggesting a slight improvement to Steve's instructions. ...
                        Alrighty... added an instruction to remind folks how to run it with ~/gethosts. And added the bit about ~/bin. (I didn't know this!)

                        Comment


                          #27
                          I'd rather be locked out than locked in.

                          Comment


                            #28
                            Cut and paste doesn't work 'cause the forum is truncating the fourth source link.

                            Please Read Me

                            Comment


                              #29
                              Fixed that...somehow, URL BBCODES snuck into there.
                              Last edited by SteveRiley; Jun 11, 2013, 11:19 PM.

                              Comment


                                #30
                                The script outputs the file ~/hosts-block. Each time you run it, you'll need to manually replace your existing host file with this command:
                                Code:

                                sudo cp ~/hosts-block /etc/hosts
                                Instead of manually doing this, why not just have it in the script? It seems to do fine for me. Also, I was thinking of using KDE's Autostart instead of a weekly cron job, but it seems there are issues with it because there are no options to run weekly, as Windows does, unless someone knows of another option?

                                Comment

                                Working...
                                X