Free Scan: Update Your PC's Outdated Drivers to Optimize Performance
February 28th, 2002, 04:10 AM
|
#1 (permalink)
| | Banned
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 |
| |
February 28th, 2002, 05:57 AM
|
#2 (permalink)
| | Ultimate Member
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... |
| |
February 28th, 2002, 06:21 AM
|
#3 (permalink)
| | Banned
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.
|
| |
February 28th, 2002, 06:32 AM
|
#4 (permalink)
| | Ultimate Member
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.
| |
| |
February 28th, 2002, 06:35 AM
|
#5 (permalink)
| | Banned
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  |
| | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |
Posting Rules
| You may post new threads You may post replies You may not post attachments You may not edit your posts HTML code is Off | | | | Most Active Discussions | | | | | Recent Discussions  | | | | | |