RE: Compare two text streams
- From: Shadrach <Shadrach@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 1 May 2007 07:47:04 -0700
I kind of understand what you mean, but I am not 100%. Can you elaborate with
code.. Sorry, I am not great with the "concept" part of Vbscript. It is still
very confusing to me...
"urkec" wrote:
I think it's because when your outer loop executes for the second time,.
objTextStream2 is already at the end of stream, so the inner loop doesn't
execute. You could move objTextStream2 = objFSO.OpenTextFile... inside the
outer loop to reopen it each time the loop executes. Or you could use str =
objTextStream2.RadAll and InStr to check if the line read from the first file
exists in the second file.
--
urkec
"Shadrach" wrote:
Please help me with this code.. Here is the situation. I need to compare 2
files with mac addresses. I will code in the match and don't match stuff..
but I need to ID (true,false) if a mac address is in one file but not the
other. Please tell me what is wrong in this code.. It only does the first
line of file one.
On Error Resume Next
'Initialize global constants and variables.
Const FOR_READING = 1
strHostFile1 = "mac1.txt"
strHostFile2 = "mac2.txt"
'******************************************************************************
'Read mac address file 1 for comparison.
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strHostFile1) Then
Set objTextStream1 = objFSO.OpenTextFile(strHostFile1, FOR_READING)
Else
WScript.Echo "Input file " & strHostFile1 & " Not found."
WScript.Quit
End If
'******************************************************************************
'Read mac address file 2 for comparison.
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strHostFile2) Then
Set objTextStream2 = objFSO.OpenTextFile(strHostFile2, FOR_READING)
Else
WScript.Echo "Input file " & strHostFile2 & " not found."
WScript.Quit
End If
'Loop through list of computers and perform tasks on each.
Do Until objTextStream1.AtEndOfStream
g_strComputer1 = objTextStream1.ReadLine
Do Until objTextStream2.AtEndOfStream
g_strComputer2 = objTextStream2.ReadLine
If (StrComp(g_strComputer1, g_strComputer2)) = 0 Then
WScript.Echo "Match: " & g_strComputer1 & " = " & g_strComputer2
Else
WScript.Echo "No Match: " & g_strComputer1 & " = " & g_strComputer2
End If
Loop
Loop
objTextStream1.Close
- Follow-Ups:
- RE: Compare two text streams
- From: urkec
- RE: Compare two text streams
- References:
- RE: Compare two text streams
- From: urkec
- RE: Compare two text streams
- Prev by Date: Re: Setting rights on an AD account using vb
- Next by Date: Re: Editing a text file
- Previous by thread: RE: Compare two text streams
- Next by thread: RE: Compare two text streams
- Index(es):
Relevant Pages
|
Loading