Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extracting subsets of text file to another file

Status
Not open for further replies.

Delboy14

Programmer
Jun 21, 2001
213
GB
C or C++

I have a text file with a list of several thousand packets, I would like to read through the text file, find relevant packets(peices of text) and write these to another file.

The packets I require look like this:

Packet #4

Flags: 0x00
Status: 0x01
Packet Length:572
Timestamp: 11:00:59.660120 03/29/2002
HTTP - HyperText Transfer Protocol
GET /dsmith/Trav 47 45 54 20 2F 64 73 6D 69 74 68 2F 54
el.asp HTTP/1.1. 65 6C 2E 61 73 70 20 48 54 54 50 2F 31
Accept: */*.. 41 63 63 65 70 74 3A 20 2A 2F 2A 0D 0A
UA-OS: Windows C 55 41 2D 4F 53 3A 20 57 69 6E 64 6F 77 Referer: http:// 52 65 66 65 72 65 72 3A 20 68 74 74 70 3A
Frame Check Sequence: 0x00000000

I would like to write relevant packets to another file, I only need some info from the packets, the information I need is:
the packet number, time stamp and the url for the GET call.

I have tried reading the text in as an array and then searching for a sub set, but cannot get the relevant info. Does anyone have any ideas?
 
If all of the packets are of a fixed size work out the offset for each portion of the data your require and then write it out to your file.

If they are not of a fixed size you might be able to use the PacketLength attribute to help calculate the offset. I'm assuming here of course that it's only the HTTP referer that is of unknown size.

HTH

William
Software Engineer
ICQ No. 56047340
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top