Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: batch script Adding Ip adresses to hosts file  (Read 13757 times)

0 Members and 1 Guest are viewing this topic.

plm

    Topic Starter


    Newbie

    batch script Adding Ip adresses to hosts file
    « on: April 06, 2009, 06:02:53 AM »
    Hi Computerhope

    I am trying to make a batch script that takes the list of Ip adresses from A.txt and appends it to B.txt with the following command:

    type B.txt>>A.txt

    content of A.txt:
    10.20.30.40
    50.60.70.80

    content of B.txt
    1.2.3.4
    5.6.7.8

    But how do i make sure that the ip adresses from B.txt are being inserted in the bottom of the A.txt file (makes a new line). My A.txt ends up looking like this:

    10.20.30.40
    50.60.70.801.2.3.4
    5.6.7.8

    Bets regards plm

    Carbon Dudeoxide

    • Global Moderator

    • Mastermind
    • Thanked: 169
      • Yes
      • Yes
      • Yes
    • Certifications: List
    • Experience: Guru
    • OS: Mac OS
    Re: batch script Adding Ip adresses to hosts file
    « Reply #1 on: April 06, 2009, 06:08:05 AM »
    Why do you want to add it to the hosts file?

    BatchFileCommand



      Hopeful
    • Thanked: 1
      Re: batch script Adding Ip adresses to hosts file
      « Reply #2 on: April 06, 2009, 06:15:59 AM »
      Oh goodie  ;D, with a file of IP Addresses you could use those to chat in school (trust me, I know how it's done)
      οτη άβγαλτος μεταφ βαθμολογία

      Reno



        Hopeful
      • Thanked: 32
        Re: batch script Adding Ip adresses to hosts file
        « Reply #3 on: April 06, 2009, 06:18:20 AM »
        /removed
        « Last Edit: April 06, 2009, 06:55:33 AM by Carbon Dudeoxide »

        gh0std0g74



          Apprentice

          Thanked: 37
          Re: batch script Adding Ip adresses to hosts file
          « Reply #4 on: April 06, 2009, 06:25:51 AM »
          /removed
          « Last Edit: April 06, 2009, 06:55:30 AM by Carbon Dudeoxide »

          Reno



            Hopeful
          • Thanked: 32
            Re: batch script Adding Ip adresses to hosts file
            « Reply #5 on: April 06, 2009, 06:30:54 AM »
            /removed
            « Last Edit: April 06, 2009, 06:55:24 AM by Carbon Dudeoxide »

            Carbon Dudeoxide

            • Global Moderator

            • Mastermind
            • Thanked: 169
              • Yes
              • Yes
              • Yes
            • Certifications: List
            • Experience: Guru
            • OS: Mac OS
            Re: batch script Adding Ip adresses to hosts file
            « Reply #6 on: April 06, 2009, 06:55:56 AM »
            Sorry guys, I removed your suggestion.  I would like to know why Plm needs to do this.

            gh0std0g74



              Apprentice

              Thanked: 37
              Re: batch script Adding Ip adresses to hosts file
              « Reply #7 on: April 06, 2009, 07:12:09 AM »
                I would like to know why Plm needs to do this.
              i would like to know why you removed them.

              Carbon Dudeoxide

              • Global Moderator

              • Mastermind
              • Thanked: 169
                • Yes
                • Yes
                • Yes
              • Certifications: List
              • Experience: Guru
              • OS: Mac OS
              Re: batch script Adding Ip adresses to hosts file
              « Reply #8 on: April 06, 2009, 07:13:11 AM »
              You want him, and the entire world, to know how to add IP address into the Hosts file?
              Do you know what that could do?

              gh0std0g74



                Apprentice

                Thanked: 37
                Re: batch script Adding Ip adresses to hosts file
                « Reply #9 on: April 06, 2009, 07:16:50 AM »
                You want him, and the entire world, to know how to add IP address into the Hosts file?
                Do you know what that could do?
                aren't you being too sensitive? he asked a legit question on how to append to files properly. Adding ip address to hosts files is just common practice anyway among system administrators. Until proven guilty, everyone is innocent.

                Carbon Dudeoxide

                • Global Moderator

                • Mastermind
                • Thanked: 169
                  • Yes
                  • Yes
                  • Yes
                • Certifications: List
                • Experience: Guru
                • OS: Mac OS
                Re: batch script Adding Ip adresses to hosts file
                « Reply #10 on: April 06, 2009, 07:18:35 AM »
                Quote
                Re: batch script Adding Ip adresses to hosts file
                Nice title.

                Anyways, this is a public forum. anyone can view the information posted here. Perfect for pranksters, eh?

                gh0std0g74



                  Apprentice

                  Thanked: 37
                  Re: batch script Adding Ip adresses to hosts file
                  « Reply #11 on: April 06, 2009, 07:23:40 AM »
                  Nice title.
                  so ?
                  Quote
                  Anyways, this is a public forum. anyone can view the information posted here. Perfect for pranksters, eh?
                  wow, why don't you remove the suggestions from the thread that that says "how to read target from shortcut"?  Do you know what would happen if a prankster changes something in that shortcut that tries to delete an important file(for example) if double clicked?

                  Reno



                    Hopeful
                  • Thanked: 32
                    Re: batch script Adding Ip adresses to hosts file
                    « Reply #12 on: April 06, 2009, 07:30:29 AM »
                    Sorry guys, I removed your suggestion.  I would like to know why Plm needs to do this.
                    no problem, i don't know if hosts file should not be edited.

                    Carbon Dudeoxide

                    • Global Moderator

                    • Mastermind
                    • Thanked: 169
                      • Yes
                      • Yes
                      • Yes
                    • Certifications: List
                    • Experience: Guru
                    • OS: Mac OS
                    Re: batch script Adding Ip adresses to hosts file
                    « Reply #13 on: April 06, 2009, 07:30:34 AM »
                    No point in arguing.

                    I have had hands-on experiencing regarding Hosts file edits. A friend created a batch file that redirected popular URLs to a website I need not mention here. He ran this batch file on several of the laptops in my class and caused a great deal of trouble in the lesson.
                    None of them knew how to undo this. They didn't know where the problem lay, nor did they know what the Hosts file was.

                    I asked Plm 'why he wanted to do this', and BatchFileCommand concurred with my assessment.
                    You went ahead and posted the potentially harmful information anyways.

                    Read the forum rules under Causing users grief / hacking.

                    You should be glad I didn't simply delete your posts and offer no reason why I did it.

                    Carbon Dudeoxide

                    • Global Moderator

                    • Mastermind
                    • Thanked: 169
                      • Yes
                      • Yes
                      • Yes
                    • Certifications: List
                    • Experience: Guru
                    • OS: Mac OS
                    Re: batch script Adding Ip adresses to hosts file
                    « Reply #14 on: April 06, 2009, 07:33:03 AM »
                    no problem, i don't know if hosts file should not be edited.

                    This Hosts file can be edited. It is edited in some situations. But take note that many viruses modify the Hosts file just to cause trouble. Large networks have special programs to monitor network traffic and block sites.

                    Imagine trying to get to www.google.com but being transferred to a site to buy a fake antivirus that steals sensitive information from your computer.