?
Solved

Small program to read log text file

Posted on 2005-04-04
3
Medium Priority
?
257 Views
Last Modified: 2010-04-06
Well in Delphi.  Somebody can make me a small program?

I'm fed up reading and analysing log files.  ftp://ftp.exceltheque.com/  Look the example of log file.  I would like to have a program that would add each identical ip address in order to see who is attempting to access my network.  

For example, i see 24.200.1.35 often.  The program could give me the amount of attempts to connect one shot without me to count them.  

I have an old delphi 1 licence to compile otherwise, could you send me an executable?  
merlin740500@hotmail.com

Do not forget to write something here too to have points.  

Thank you,

M.
0
Comment
Question by:Merlin740500
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
shaneholmes earned 2000 total points
ID: 13704221
I have sent you a zipped up executable with source

sholmes

See code below:


unit untMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls;

type
  TfrmMain = class(TForm)
    pnlTop: TPanel;
    pnlBottom: TPanel;
    btnLoad: TButton;
    dlgOpen: TOpenDialog;
    lbxItems: TListBox;
    procedure btnLoadClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmMain: TfrmMain;

implementation

{$R *.dfm}

procedure TfrmMain.btnLoadClick(Sender: TObject);
var
 AList: TStringList;
 I: Integer;
begin
 if dlgOpen.Execute then
 begin
  AList:= TSTringList.Create;
  AList.LoadFromFile(dlgOpen.FileName);
  for I:= 1 to AList.Count - 1 do
  begin
   if Pos('Blocked access attempt from',AList[I]) > 0 then
    lbxItems.Items.Add(Copy(AList[I],50, Length(AList[I])) + ' - ' + 'Blocked access' + ' - ' +
                       Copy(Alist[I],1,18))
   else
   if Pos('login Successful', Alist[I]) > 0 then
    lbxItems.Items.Add(Copy(AList[I],22, pos('login Successful',AList[I])- 22) + ' - ' +  'login Successful' + ' - ' +
                       Copy(Alist[I],1,18))
   else
   if Pos('logout', Alist[I]) > 0 then
    lbxItems.Items.Add(Copy(AList[I],22, pos('logout',AList[I])-22) + ' - ' +  'logout' + ' - ' +
                       Copy(Alist[I],1,18));

  end;
  AList.Free;
 end;
end;

end.
0
 
LVL 2

Author Comment

by:Merlin740500
ID: 13705878
Your codes impress me, it is efficient!

I've taken a course at the university ten years ago and never practice since.  Just able to follow the program!
0
 
LVL 11

Expert Comment

by:shaneholmes
ID: 13705915
Thanx for the points!

I have included comments for you to follow

procedure TfrmMain.btnLoadClick(Sender: TObject);
var
 AList: TStringList;
 I: Integer;
begin

 //execute the open file dialog box
 if dlgOpen.Execute then
 begin
  // create a list to temporarily store entire file
  AList:= TSTringList.Create;

  //load entire file into temp list
  AList.LoadFromFile(dlgOpen.FileName);

 // iterate through each line in file
  for I:= 1 to AList.Count - 1 do
  begin
   
   //test for the position of 'Blocked access attempt from' in the line
   if Pos('Blocked access attempt from',AList[I]) > 0 then
    rearrange each part of the line so that the Ip address goes first
    lbxItems.Items.Add(Copy(AList[I],50, Length(AList[I])) + ' - ' + 'Blocked access' + ' - ' +
                       Copy(Alist[I],1,18))
   else
  // do the same for others down below

   if Pos('login Successful', Alist[I]) > 0 then
    lbxItems.Items.Add(Copy(AList[I],22, pos('login Successful',AList[I])- 22) + ' - ' +  'login Successful' + ' - ' +
                       Copy(Alist[I],1,18))
   else
   if Pos('logout', Alist[I]) > 0 then
    lbxItems.Items.Add(Copy(AList[I],22, pos('logout',AList[I])-22) + ' - ' +  'logout' + ' - ' +
                       Copy(Alist[I],1,18));

  end;
  AList.Free;
 end;
end;



Hope this helps!

Sholmes
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question