readout ip-addresses to a single txt file - TechRepublic
General discussion
September 25, 2010 at 05:01 AM
t8pmusic

readout ip-addresses to a single txt file

by t8pmusic . Updated 15 years, 9 months ago

Hello,

Im working on a script that will read ip-addresses from *.eml files and to put them in a single txt file so that i only have to copy/paste them in the spam/blacklisted server.

What i have so far;

the script itself (spam_ip.vbs)

Const ForReading = 1

Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set folder = objFSO.GetFolder(“z:\test\”)

for each file in folder.Files

if lcase(objFSO.getExtensionName(file.path))=”eml” then

Set objFile = objFSO.OpenTextFile(file.path, ForReading)

strSearchString = objFile.ReadAll
objFile.Close

Set objRegEx = CreateObject(“VBScript.RegExp”)

objRegEx.Global = True
objRegEx.Pattern = “\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}”

Set colMatches = objRegEx.Execute(strSearchString)

For Each strMatch in colMatches
If Left(strMatch.Value, 3) <> “255” Then
Wscript.Echo strMatch.Value
End If
Next

If colMatches.Count > 0 Then
For Each strMatch in colMatches
Wscript.Echo strMatch.Value
Next
End If
End If

——-

to get it in a file i use a bat file spam.bat

cscript spam_ip.vbs > spam.txt

——

The problem that im having is that ill get an error when running the vb script (loop detected) and i can’t figure out why.

Can someone help with this ?

Fred

This discussion is locked

All Comments