This is a multi-part message in MIME format.
------=_NextPart_000_0008_01C8A9F3.D5EC7650
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hello,
I am looking for a script to compare two files.
Scan second file using the words from first file.=20
Extract the line that matches the word from second file
I have a sample script that matches but I don't know how to extract the =
line
File1:
tom
peter
joseph
File2:
192.168.0.0, this is sql users, tom, testmachine
192.168.1.2, this is mysql users, john, testmachine2
192.168.0.0, this is sql users, joseph, testmachine5
192.168.0.0, this is sql users, maria, testmachine6
192.168.0.0, this is sql users, donald, testmachine7
Output:
192.168.0.0, this is sql users, tom, testmachine
192.168.0.0, this is sql users, joseph, testmachine5
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Here is the sample code:
Const ForReading =3D 1
Set objFSO =3D CreateObject("Scripting.FileSystemObject")
Set objFile1 =3D objFSO.OpenTextFile("C:\Audit\User_Info.txt", =
ForReading)
strAddresses =3D objFile1.ReadAll
objFile1.Close
Set objFile2 =3D objFSO.OpenTextFile("C:\Audit\User_First_Name.txt", =
ForReading)
Do Until objFile2.AtEndOfStream
strCurrent =3D objFile2.ReadLine
If InStr(strAddresses, strCurrent) <> 0 Then
strNoAddress =3D strNoAddress & strCurrent & vbCrLf
End If
Loop
objFile2.Close
Wscript.Echo "Devices with no address: " & vbCrLf & strNoAddress
Set objFile3 =3D objFSO.CreateTextFile("C:\Audit\User_New_Info.txt")
objFile3.WriteLine strNoAddress
objFile3.Close
------=_NextPart_000_0008_01C8A9F3.D5EC7650
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.3790.3959" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3D"Arial Narrow" size=3D2>Hello,</FONT></DIV>
<DIV><FONT face=3D"Arial Narrow" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Arial Narrow" size=3D2>I am looking for a script to =
compare two=20
files.</FONT></DIV>
<DIV><FONT face=3D"Arial Narrow" size=3D2>Scan second file using =
the words from=20
first file. </FONT></DIV>
<DIV><FONT face=3D"Arial Narrow" size=3D2>Extract the line that matches =
the word=20
from second file</FONT></DIV>
<DIV><FONT face=3D"Arial Narrow" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Arial Narrow" size=3D2>I have a sample script that =
matches but I=20
don't know how to extract the line</FONT></DIV>
<DIV><FONT face=3D"Arial Narrow" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Arial Narrow" =
size=3D2><STRONG>File1:</STRONG></FONT></DIV>
<DIV><FONT face=3D"Arial Narrow" size=3D2>tom</FONT></DIV>
<DIV><FONT face=3D"Arial Narrow" size=3D2>peter</FONT></DIV>
<DIV><FONT face=3D"Arial Narrow" size=3D2>joseph</FONT></DIV>
<DIV><FONT face=3D"Arial Narrow" size=3D2></FONT> </DIV>
<DIV><FONT face=3D"Arial Narrow" =
size=3D2><STRONG>File2:</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>192.168.0.0, this is sql users, tom,=20
testmachine</FONT></DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2>192.168.1.2, this is mysql users, john, =
testmachine2</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>192.168.0.0, this is sql users, joseph, =
testmachine5</FONT></DIV>
<DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2>192.168.0.0, this is sql users, maria,=20
testmachine6</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>192.168.0.0, this is sql users, donald, =
testmachine7</FONT></DIV></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT> </DIV>
<DIV><FONT face=3DArial size=3D2><STRONG>Output:</STRONG></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>192.168.0.0, this is sql users,=20
<STRONG>tom</STRONG>, testmachine</FONT></DIV>
<DIV>
<DIV><FONT face=3DArial size=3D2>192.168.0.0, this is sql users,=20
<STRONG>joseph</STRONG>, testmachine5</FONT></DIV>
<DIV> </DIV>
<DIV>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</DIV>
<DIV>Here is the sample code:</DIV>
<DIV>Const ForReading =3D 1</DIV>
<DIV> </DIV>
<DIV>Set objFSO =3D CreateObject("Scripting.FileSystemObject")<BR>Set =
objFile1 =3D=20
objFSO.OpenTextFile("C:\Audit\User_Info.txt", ForReading)</DIV>
<DIV> </DIV>
<DIV>strAddresses =3D objFile1.ReadAll<BR>objFile1.Close</DIV>
<DIV> </DIV>
<DIV>Set objFile2 =3D =
objFSO.OpenTextFile("C:\Audit\User_First_Name.txt",=20
ForReading)</DIV>
<DIV> </DIV>
<DIV>Do Until objFile2.AtEndOfStream<BR> strCurrent =
=3D=20
objFile2.ReadLine<BR> If InStr(strAddresses, =
strCurrent)=20
<> 0 Then<BR> =
strNoAddress =3D=20
strNoAddress & strCurrent & vbCrLf<BR> End=20
If<BR>Loop</DIV>
<DIV> </DIV>
<DIV>objFile2.Close</DIV>
<DIV> </DIV>
<DIV>Wscript.Echo "Devices with no address: " & vbCrLf &=20
strNoAddress</DIV>
<DIV> </DIV>
<DIV>Set objFile3 =3D =
objFSO.CreateTextFile("C:\Audit\User_New_Info.txt")</DIV>
<DIV> </DIV>
<DIV>objFile3.WriteLine=20
strNoAddress<BR>objFile3.Close</DIV></DIV></FONT></DIV></DIV></DIV></DIV>=
</BODY></HTML>
------=_NextPart_000_0008_01C8A9F3.D5EC7650--