home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Ask a Tech Support Question (free)!

tally up frequency of a string and write it to a file...?

Reply
Get bargains at  »  Dealighted.com
 
Thread Tools Search this Thread
Currently Active Users: 1943
Discussions: 200,992, Posts: 2,379,902, Members: 246,360
Old February 28th, 2002, 04:10 AM   Digg it!   #1 (permalink)
Banned
 
Chooco's Avatar
 
Join Date: Feb 2002
Posts: 804
tally up frequency of a string and write it to a file...?

i run a Counter-Strike server with a thing called CSguard. it bans people quite often for using very common hacks such as HLH (Half Life Hacked) or OGC. what i want to do is write a script to open the certain file (just 1 file) and detect how often the string "ogc" and "HLH" appear then write that to a file such as
&ogc OGC hackers total
&hlh HLH hackers total

i'm only up to like chapter 6 of C++ for dummies so i don't know the commands lol.

all i need to know is the command to detect a string in a specified file and how to make C++ write a file with the results
Chooco is offline   Reply With Quote
Old February 28th, 2002, 05:57 AM     #2 (permalink)
Ultimate Member
 
strangerstill's Avatar
 
Join Date: Oct 2001
Posts: 1,542
You can do this in DOS quite easily

Just write a batch file

find /c /i "OGC" < CSguard.log > hacklog.txt
echo OGC hackers total >> hacklog.txt
find /c /i "HLH" < CSguard.log >> hacklog.txt
echo HLH hackers total >> hacklog.txt

Only problem is output file will have nasty line breaks. Not sure how to get round that one...
strangerstill is offline   Reply With Quote
Old February 28th, 2002, 06:21 AM     #3 (permalink)
Banned
 
Chooco's Avatar
 
Join Date: Feb 2002
Posts: 804
what do the /c and /i mean?
what exactly is a batch file anyway. is it compiled by anything?

*edit*
OMG THAT IS SO COOL!!! a batch file doesn't need to be compiled? no way! lol
excellent program man, thanks

Last edited by Chooco : February 28th, 2002 at 06:29 AM.
Chooco is offline   Reply With Quote
Old February 28th, 2002, 06:32 AM     #4 (permalink)
Ultimate Member
 
strangerstill's Avatar
 
Join Date: Oct 2001
Posts: 1,542
Hmm. Are you running XP Professional? If so running hh ntcmds.chm will bring up the helpfile on the XP command line.

Otherwise, a batch file is a text file with the extension .bat that consists of a series of DOS commands on subsequent lines. DOS reads the batch file and executes each line in turn as if it was typed in at the command prompt. There's slightly more to it than that - some basic flow control and variable support, like a script file. Batch files have been part of DOS since the early days, recently they have been somewhat superceded by the Windows Scripting Host (VBScript/JScript) but batch files still remain the easiest way to quickly automate simple tasks.

As for the switches on find, /c means to just count the number of occurences (rather than outputting every single line that the search string appears in), /i means that it the search is case insensitive. Type find /? at the command prompt for more.

Here's what Microsoft say about batch files:
Quote:
Using batch files

With batch files, which are also called batch programs or scripts, you can simplify routine or repetitive tasks. A batch file is an unformatted text file that contains one or more commands and has a .bat or .cmd file name extension. When you type the file name at the command prompt, Cmd.exe runs the commands sequentially as they appear in the file.

You can include any command in a batch file. Certain commands, such as for, goto, and if, enable you to do conditional processing of the commands in the batch file. For example, the if command carries out a command based on the results of a condition. Other commands allow you to control input and output and call other batch files.

strangerstill is offline   Reply With Quote
Old February 28th, 2002, 06:35 AM     #5 (permalink)
Banned
 
Chooco's Avatar
 
Join Date: Feb 2002
Posts: 804
so a batch file is like a plugin for DOS. the real program is like batch.exe or something and the plugin would be hacklog.bat...........interesting
Chooco is offline   Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Most Active Discussions
Is It Just Me? (3083)
Charges against non-tippers dropped.. (20)
Health Care Rationing (13)
Delete an OS (17)
Nvidia GTX 260 problem (10)
Laptop with wireless problem. (12)
Wireless Televisions. (12)
windows vista security holes (19)
CPU fan stops spinning randomly (11)
Regular Build (11)
Point and Shoot Camera Suggestions. (8)
[F@H SPAM 11/16/09] ! 1/2 months to.. (40)
windows 7 problem (7)
Internet Lost (5)
Recent Discussions
Print spooler problem (17)
[F@H SPAM 11/16/09] ! 1/2 months to r.. (40)
Foxconn Blackops x48 MoBo (3)
Q9650 vs. Q9550 (2)
Desktop Calendar Application (2)
Looking for new motherboard (1)
soundmon.exe (8)
Jedi Academy Problem (3)
Can a page file be "too big".. (1)
Nvidia GTX 260 problem (10)
Point and Shoot Camera Suggestions. (8)
Size after cutting 700Mb file is 2.5 .. (0)
Delete an OS (17)
windows vista security holes (19)
updating BIOS via winflash, claims fi.. (1)
New Server Configuration Suggestions (0)
cheap gaming laptop? (12)
Unallocated Space (2)
help me pls laptop just stopped worki.. (1)
C# + LINQ Help (7)
Dynex DX E-402 (3)
EVGA 9800 gtx help with finding a goo.. (12)
Multiple Restarts Required at Boot (5)
cell phone won't work (0)
Is the PSU I received dead? (15)


All times are GMT -4. The time now is 09:45 AM.
TechIMO Copyright 2009 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28