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

Author Topic: Writing Bat Command to pull Ip addresses from a Text file to run a scripted exe  (Read 4910 times)

0 Members and 1 Guest are viewing this topic.

Twilighttime

    Topic Starter


    Newbie

    Good Day everyone,

    Thank you for taking the time to look at my request.

    I currently have a  bat file that has this line. it runs that executable.

    RebootAllPOEPorts.exe /r:POE1.txt /o:output/POE1.txt /m

    the executable initiates a telnet session and runs the POE1.txt file. basically a scripted telnet session.

    The POE1.txt file looks like this:

    172.16.1.1
    WAIT "Login:"
    SEND "current password\m"
    .... more commands follow

    Currently i use this to log into a varying amount of POE's depending on the site and reset all the ports within that poe. In order for me to achieve this i am using the following bat command when i have 2 switches at a site

    RebootAllPOEPorts.exe /r:POE1.txt /o:output/POE1.txt /m
    RebootAllPOEPorts.exe /r:POE2.txt /o:output/POE2.txt /m

    so it is very redundant and time consuming especially when i have 30+ POE's and i need to create a line and and i need to create a new POEx.txt file to represent each POE since the IP address is different.

    What i would really like is the following

    Basic Change:

         To have the main bat file prompt the user for the starting IP address and the ending IP address sequentially run the RebootALLPOEPorts.exe command.
         
         the first line of the scripting text file the execuble reads is the IP address. That would need to be different for each one.

    so in essence it would be somethign like this:

    RebootPoE.bat

    Ask user to input starting iP address
    Ask user to input ending Ip address ( only last octet would change . ie 172.16.1.30)

    Run this executable multiple times. once each for each IP address in that range. IP would be in the POEx.txt
    RebootAllPOEPorts.exe /r:POEx.txt /o:output/POEx.txt /m

    The output file would also need to increment with the repeat of this command so there is a log for each POE interaction.

    I guess this needs to be some kind of looping crazy smart bat file. :)

    Please help! i will be monitoring this all day to give more feedback if needed!!

    Prince_



      Beginner

      Thanked: 5
      not that patient to spend much time reading your question...
      i guess that you are a writer... ;D

      Geek-9pm


        Mastermind
      • Geek After Dark
      • Thanked: 1026
        • Gekk9pm bnlog
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      What's the problem? You say they only vary in the last octet. So there would only be 256 possible files  you need.  Even if each was 4000 byes that should only be a total of one megabyte.
      So just make the d256  files, give each a name with the number in it. Like maybe you could call them job000.bat, job001.bat, job.002.bat, ... job254.bat, job255.bat and you would invoke them with a batch file you may call myjob.nat which would look like this:

      Code: [Select]
      call job%1.bat
      rem all done!
      And you would invoke it like this
      Code: [Select]
      Microsoft Windows XP [Version 5.1.2600]
      (C) Copyright 1985-2001 Microsoft Corp.

      d:\batch>myjob 174
      job174.bat
      Welcome to Microsoft Telnet Client

      rem all done!
      d:\batch>
      Is that what you want?