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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find IP address in files FSO?

Status
Not open for further replies.

benniesanders

Programmer
Jan 20, 2002
199
US
Greetings,

I have a gazillion files that an old, bad IP address could be buried in. Is there a way to open the files using FSO, look for that IP address and response write the filename? I've used this code in the past to get a file list excluding images. I'm not smart enough to figure out how to take it one step further and look inside the file for the IP address. Any help would be appreciated. Thank you.
Code:
<body>
<% 
'Server.ScriptTimeOut = 10000
Dim Path

Path = Server.MapPath("/") 
%>
<font size = 2 face="arial, helvetica, sans-serif">
<%
Response.Write("Using path: " & Path & "<p>") 
%>
</font>
<%
Dim fs, fso, f, Folder, fc, s, File, Name, arrayFiles(5000), sTmp(1), i, j, n  
Set fs = CreateObject("Scripting.FileSystemObject") 
%><font size = 1 face="arial, helvetica, sans-serif"><% 
Call ScanFolders(Path) 
%></font><% 

Function ScanFolders(PathSpec) 

Response.Write(PathSpec & "<br>") 
Response.Write("<BLOCKQUOTE>") 
Set f = fs.GetFolder(PathSpec) 
Set fc = f.Files 

'-- Fill the array
i = 0 
For Each f1 in fc 
i = i+1 
 arrayFiles(i) = LCase(Cstr(f1.Name))
Next
n = i 
For i = 1 to n 
  For j = 1 to i 
     If arrayFiles(i) < arrayFiles(j) Then 
        sTmp(1) = arrayFiles(i) 
        arrayFiles(i) = arrayFiles(j) 
        arrayFiles(j) = sTmp(1) 
    End if 
  Next 
Next 
For i = 1 to n
allFiles = UCase(arrayFiles(i)) 
rPath = Replace(PathSpec, Path, "")
'Response.Write rPath
'If Instr(allFiles,".HTM") OR Instr(UCase(allFiles),".HTML") Then 
'Response.Write("<TR><TD><A HREF=" & PathSpec & "\" & arrayFiles(i)  & "><Font color=red>" & arrayFiles(i) & "</a><br></font></TD></TD>") 
If  Instr(allFiles,".ASP") Then 
Response.Write("<TR><TD><A HREF="& rPath &"/"& arrayFiles(i)  & "><Font color=blue>" & arrayFiles(i) & "</a><br></font></TD></TD>") 


End If 
Next 

%>
</BLOCKQUOTE>
<% 
Set f = Fs.GetFolder(PathSpec) 
Set fc = f.SubFolders 
For Each Folder in fc 
       Response.Write("<BLOCKQUOTE>") 
Call ScanFolders(PathSpec & "\" & Folder.Name) 
Response.Write("</BLOCKQUOTE>") 
     Next 
End Function 
%>
<font size = 2 face="arial, helvetica, sans-serif">
<%
Response.Write("No more files")
%> </body>
</html>
 
I figured it out. I took an old search routine and used the IP address as the search text. It worked. Many thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top