Suggestions?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
J3hx
Posts: 1
Joined: 29 May 2015 12:56

Suggestions?

#1 Post by J3hx » 29 May 2015 13:09

What would be my best option if I wanted to create a batch that would take a list of IP addresses(text file maybe?), and generate the following:

edit "Mal-ip *"
Set associated-interface ''
Set color 0
Set comment ''
Set visibility enable
Set subnet * 255.255.255.255
next

I'd like it to take a list of IPs and replace the * with the IP address, either by line or easiest method? This is for generating a command to add multiple ips to a block list via cli. Currently I have a text file I have to add each ip individually.. Would like to automate this if possible to speed up the process. I'm not asking for anyone to provide me the code but rather point me in the right direction or some example links.. Or if there's a better way to do this I'm open to suggestions. Thanks!!

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: Suggestions?

#2 Post by foxidrive » 30 May 2015 01:02

If the task is to replace two * with an IP address on each line in a text file - this is easy (but untested):

Code: Select all

@echo off
(
for /f "usebackq delims=" %%a in ("c:\folder\IPlistfile.txt") do (
echo(edit "Mal-ip %%a"
echo(     Set associated-interface ''
echo(     Set color 0
echo(     Set comment ''
echo(     Set visibility enable
echo(     Set subnet %%a 255.255.255.255
echo(next
echo(
)
)>"newfile.txt"

Post Reply