How do I find a certain text in a document??

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
larrybrac
Newbie
Posts: 2
Joined: Mon Jan 12, 2004 6:01 am

How do I find a certain text in a document??

Post by larrybrac » Mon Jan 12, 2004 4:14 pm

All I want to do is search a known simple text document for 1 specific word of text and if it is in the document, play a wav file, if not close the program. I have to check my company bbs once per hour and search for this keyword. If it is there I want the computer to notify me. The keyword is "green", and the document is c:\new.txt. I know this is extremely basic, but I can't figure it out. Thanks

Lumumba

Post by Lumumba » Mon Jan 12, 2004 10:47 pm

Label>FileCheck
IfFileExists>c:\new.txt,Grep
Wait>1
Goto>FileCheck

Label>Grep
Run Program>cmd /c find /c "green" c:\new.txt > c:\green.log
ReadLn>c:\green.log,2,line
Length>line,llenght
Sub>llenght,23
MidStr>%line%,24,%llenght%,result
If>result0,PlayThatFunkyMusicWildBoy
Goto>Cleaner

Label>PlayThatFunkyMusicWildBoy
PlayWav>%WIN_DIR%\media\chimes.wav

Label>Cleaner
Del>c:\new.txt
Del>c:\green.log
Goto>FileCheck

larrybrac
Newbie
Posts: 2
Joined: Mon Jan 12, 2004 6:01 am

Thank You

Post by larrybrac » Tue Jan 13, 2004 3:57 am

Thank you very much, I'll try it tonight.

User avatar
tony_smith
Pro Scripter
Posts: 70
Joined: Wed May 14, 2003 8:25 pm
Location: Vancouver BC Canada

Grep?

Post by tony_smith » Wed Jan 14, 2004 7:13 pm

Grep? LAMUMBA... your Unix is showing

Lumumba

Post by Lumumba » Thu Jan 15, 2004 11:02 am

Well, regardless that I've to work with Billy Gates toy, it's never to late to work smart :wink: --> even with Windows. Check this page: Cygwin or GNU

Download: GREP or the rest of the story like:

Textutils (which is included in the CoreUtils) contains the following software:

cat- concatenates and prints files on the standard output
cksum- checksum and count the bytes in a file
comm- compares two sorted files line by line
csplit- splits a file into sections determined by context lines
cut- remove sections from each line of files
expand- convert tabs to spaces
fmt- simple optimal text formatter
fold- wrap each input line to fit in specified width
head- output the first part of files
join- join lines of two files on a common field
md5sum- compute and check MD5 messsage digest
nl- number lines of files
od- dump files in octal and other formats
paste- merge lines of files
ptx- produce a permuted index of file contents
pr- convert text files for printing
sort- sort lines of text files
split- split a file into pieces
sum- checksum and count the blocks in a file
tac- concatenates and prints files in reverse
tail- outputs the last part of files
tr- translates or deletes characters
tsort- perform topological sort
unexpand- convert spaces to tabs
uniq- remove duplicate lines from a sorted file
wc- prints the number of bytes, words, and lines in files

Download

FYI: you should check the tools in detail eg. TAIL used with the parameter -f could be used as a realtime process log viewer :!: ...

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts