How do I compare two text files with a list of computers in them? The
files were created using the (object.writeline %computername%, vbCrLf)
command. I have a vbscript that queries SMS each day for active
computer accounts. I don't care about any new accounts only the ones
that are missing from the text file the day before.Thanks in advance,

SMS_day1.txt
****************
Computer1
Computer2
Computer3
Computer4

SMS_day2.txt
******************
Computer2
Computer3
Computer5
Computer7
Computer8

I want to know which computers SMS deletes from it's database each
day.

Re: Compare two text files by \

\
Thu Dec 01 09:15:52 CST 2005

> How do I compare two text files with a list of computers in them? The
> files were created using the (object.writeline %computername%, vbCrLf)
> command. I have a vbscript that queries SMS each day for active
> computer accounts. I don't care about any new accounts only the ones
> that are missing from the text file the day before.Thanks in advance,

The script below compares the two files and sends a list of missing computers to
third list. It is assumed that the two logs contains nothing but a list of
computers, one computer per line, no headers, footers or notes. If that is not
true, the logs will have to be cleaned up before they are processed.

'--------------------SMS_gone.vbs-----------------
Set fso=CreateObject("Scripting.FileSystemObject")

Set txtfile=fso.OpenTextFile("SMS_day1.txt")
data=txtfile.readAll
txtfile.close

txtArray=split(data,vbCRLF)

Set txtfile=fso.OpenTextFile("SMS_day2.txt")
data=txtfile.readAll
txtfile.close

dim list

for n=0 to ubound(txtArray)
if instr(data,txtArray(n))=0 then list=list & txtArray(n) & vbCRLF
next

Set txtfile=fso.CreateTextFile("SMS_gone.txt")
txtfile.write list
txtfile.close
'-----------------------------------------
--
Crash



Re: Compare two text files by Chris

Chris
Wed Dec 14 07:37:58 CST 2005

Hey Crash,

I saw this script and thought I could make use of it as well. But
when I run it, it the SMS_gone.txt file always contains the exact same
lines as SMS_day1.txt

suggestions?

......Chris


cmoorhead@mindspring.com

On Thu, 1 Dec 2005 10:15:52 -0500, "\"Crash\" Dummy"
<dvader@deathstar.mil> wrote:

>> How do I compare two text files with a list of computers in them? The
>> files were created using the (object.writeline %computername%, vbCrLf)
>> command. I have a vbscript that queries SMS each day for active
>> computer accounts. I don't care about any new accounts only the ones
>> that are missing from the text file the day before.Thanks in advance,
>
>The script below compares the two files and sends a list of missing computers to
>third list. It is assumed that the two logs contains nothing but a list of
>computers, one computer per line, no headers, footers or notes. If that is not
>true, the logs will have to be cleaned up before they are processed.
>
>'--------------------SMS_gone.vbs-----------------
> Set fso=CreateObject("Scripting.FileSystemObject")
>
>Set txtfile=fso.OpenTextFile("SMS_day1.txt")
>data=txtfile.readAll
>txtfile.close
>
>txtArray=split(data,vbCRLF)
>
>Set txtfile=fso.OpenTextFile("SMS_day2.txt")
>data=txtfile.readAll
>txtfile.close
>
>dim list
>
>for n=0 to ubound(txtArray)
> if instr(data,txtArray(n))=0 then list=list & txtArray(n) & vbCRLF
>next
>
>Set txtfile=fso.CreateTextFile("SMS_gone.txt")
>txtfile.write list
>txtfile.close
>'-----------------------------------------