Page 1 of 1 1
Topic Options
#204028 - 2012-01-09 08:36 AM reading from text files
robertazo Offline
Just in Town

Registered: 2012-01-08
Posts: 2
Loc: Germany

I'm rather new to vbscript and it would be very much appreciated if one of you could help me out. I have the following problem:
Basically I have some log files (from robocopy) and I want to search inside of those log files for a certain word.
I've done that using the FileSystemObject what works fine but in my output, each time the word was found in a line it's being echoed out. I just want to have an output telling me only one time if the word has been found or not, even if the word I'm searching for exists many times within the log file.
Also it would be great if I could additionally echo out the name of the log files containing the world I'm searching for.

Thank you very much for your help!

#204030 - 2012-01-09 09:18 AM Re: reading from text files [Re: robertazo]
Mart Moderator Offline
KiX Supporter

Registered: 2002-03-27
Posts: 4669
Loc: The Netherlands
If you are looking for a vbscript solution then you are on the wrong site because this forum is about kixtart and not vbs.

In kix this is simple. Just open the file, read one line, check the line, read the next line and close the file at the end. See below for an example.

Break on

$rc = Open(1, "D:\somefile.txt", 2)

$line = ReadLine(1)

While @ERROR = 0
	If InStr($line, "wordtofind")
		$found = "yes"
	$line = ReadLine(1)

$rc = Close(1)

If $found = "yes"
	? "Found the requested word in one or more lines."
	? "Did not find the requested word in one or more lines."

Sleep 5

- Chuck Norris once sold ebay to ebay on ebay.

#204031 - 2012-01-09 09:39 AM Re: reading from text files [Re: Mart]
robertazo Offline
Just in Town

Registered: 2012-01-08
Posts: 2
Loc: Germany
Hi Mart,

thanks for that, my fault. Appreciated your help!


Page 1 of 1 1

Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 310 anonymous users online.
Newest Members
Kelly001, MichaelK72, Janneman, standardbruker, maikoenig2001
17773 Registered Users

Generated in 0.029 seconds in which 0.012 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google: