Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need some help 1

Status
Not open for further replies.

North323

Technical User
Jan 13, 2009
966
US
I am not a vb scripter by no means. I have a text file of IP addresses and I would like to append this file to say something like:

We should block 192.168.1.1 Please do this now.

The text file has the IP addresses like so:
192.168.1.1
192.168.1.2
 
What have you tried so far and where in your code are you stuck ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
i have tried search google for examples. i have not started any code. i have no idea where to start.
 
Hmm, go on then, I'm bored at work and in a generous mood so here's a script that will do the job on your sample data (assuming you want all of the IP addresses in the textfile)...
Code:
Dim MyString

With CreateObject("VBScript.RegExp")
.MultiLine = True
.Global = True
.IgnoreCase = True
.Pattern = "(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
MyString = .Replace(CreateObject("Scripting.FileSystemObject").OpenTextFile("MyFile", 1, False).ReadAll, "We should block $1 Please do this now.")
End With

CreateObject("Scripting.FileSystemObject").OpenTextFile("MyFile2", 2, True).Write MyString

wscript.echo "Done!"
That will append the required text to all of the IP addresses in the file (replace "MyFile" with the file path) and output to another file (replace "MyFile" with the file path).

If you need anything clarifying please post back.

Regards

Andy
---------------------------------
Zebracorn: 50% Zebra, 50% Unicorn = 100% Real.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top