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

Author Topic: dos help  (Read 2119 times)

0 Members and 1 Guest are viewing this topic.

blastman

    Topic Starter


    Hopeful

    dos help
    « on: September 02, 2007, 08:16:58 AM »
    hey all,

    if i saved a txt file with a ip address in, say 127.0.0.1, and called it a.txt, could i use that data in a dos command??

    i.e,

    ping >a.txt would it do (ping 127.0.0.1)

    if not, is there a way?

    any ideas???

    Blastman, you are the man. Thank You Very Much!!!!!!!!!



    gpl



      Apprentice
    • Thanked: 27
      Re: dos help
      « Reply #1 on: September 02, 2007, 10:44:44 AM »
      if you have a single ip address in a file (and it is on the first line), you could do this

      set /P MyIP=<a.txt
      ping %MyIP%



      Graham

      blastman

        Topic Starter


        Hopeful

        Re: dos help
        « Reply #2 on: September 02, 2007, 01:32:26 PM »
        hey cheers for that, it's just what i was after. ;)

        Having mastered that, i now find myself in a slightly different, but yet equally annoying position.  ::)

        that is to say that i can write said IP address to a text file, "127.0.0.1 >a.txt", but i can't get it write that last value on the command line instead (which is what i really require).

        i have been thinking along the lines of;

        %1 >a.txt

        but when run from a prompt "test.bat 127.0.0.1" it doesn't write the IP to the txt file.

        any ideas?

        cheers again.

        any ideas?

        Blastman, you are the man. Thank You Very Much!!!!!!!!!



        GuruGary



          Adviser
          Re: dos help
          « Reply #3 on: September 02, 2007, 09:14:32 PM »
          Running it that way, the IP address would be stored in %1.  So if I understand what you want, then your test.bat could contain:
          Code: [Select]
          @echo off
          echo The passed value is %1
          ping %1

          Then you could run it
          test.bat 127.0.0.1

          Or if you really do want to write the passed value to a text file, then use the ECHO command like
          Code: [Select]
          echo %1 >a.txt