Jump to content

Convert log file to SQL database?


JeremyE
 Share

Recommended Posts

Hey, I'm not even sure where to start with this one, I have a log file that I need to access at a certain time every day, check if it's open in another process, if it is wait until I can access it, move the file to another location (for ease of use with the rest of my script), then take the info from the logfile and convert it to SQL, which is then appended to a master SQL database. Not asking for much, am I? lol

Anyway, here's an example of the logfile that I need copied, I can make fields out of this anyway I want to, I just need help with everything else.

[2008-08-04 14:29:07] Account ## [XXXXXXXXXX], IP ***.***.***.***, Player XXXXXXXXXX :: summoned XXXXXXXXXX on map 0, -4820.226074

As you can see, it has the time/date stamp, then everything else I can create fields for. Any help anyone can give me would be greatly appreciated.

Link to comment
Share on other sites

$string = '[2008-08-04 14:29:07] Account ## [XXX], IP ***.***.***.***, Player YYY :: summoned ZZZ on map 0, -4820.226074'
$array = StringRegExp($string,'\[(.*?)\] Account ## \[(.*?)\], IP (.*?), Player (.*?) :: summoned (.*?) on map (.*?), (.*)',3)
For $X = 0 to Ubound($array)-1
    ConsoleWrite('['&$X&']: ' & $array[$X] & @CRLF)
Next

Output:

[0]: 2008-08-04 14:29:07
 [1]: XXX
 [2]: ***.***.***.***
 [3]: YYY
 [4]: ZZZ
 [5]: 0
 [6]: -4820.226074
Edited by weaponx
Link to comment
Share on other sites

$string = '[2008-08-04 14:29:07] Account ## [XXX], IP ***.***.***.***, Player YYY :: summoned ZZZ on map 0, -4820.226074'
$array = StringRegExp($string,'\[(.*?)\] Account ## \[(.*?)\], IP (.*?), Player (.*?) :: summoned (.*?) on map (.*?), (.*)',3)
For $X = 0 to Ubound($array)-1
    ConsoleWrite('['&$X&']: ' & $array[$X] & @CRLF)
Next

Output:

[0]: 2008-08-04 14:29:07
 [1]: XXX
 [2]: ***.***.***.***
 [3]: YYY
 [4]: ZZZ
 [5]: 0
 [6]: -4820.226074

Only thing I'd have to change with that is the last part would be one field, from :: on... So now how do I get this into an SQL database? I've never worked with SQL using AutoIt before.

Link to comment
Share on other sites

Honestly, I know absolutely nothing about SQL, but I'm looking over that post to try and learn everything.

So you mean you don't actually have a SQL server running? If not, this is the wrong forum to get you started.

Link to comment
Share on other sites

So you mean you don't actually have a SQL server running? If not, this is the wrong forum to get you started.

I have an SQL server and everything, the reason why I need to make it SQL is so that the administrator can access everything via website.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...