Reading files backwards

MisterX mister.x at win.be
Mon Apr 22 11:02:01 EDT 2002


Then it's a simple case of

get last line of url thisurl
get last line of it

(can be written in 1 line)

--

Problem with "get url thisurl" is that the whole file will be read...

Doing this even on a 10 minute schedule (it's what I do), on a file of 3 to
20 MBs (even just 3) is going to be memory intensive... not every
efficient... On a fast network, it's ok... but on a cloggued or laggy net
connection... you're going to pull your hair out!

Consulting the read file documentation revealed that you can read at an
offset for a given length. So, you'll have to get the detailed file
information of folder above the file, filter your file, read the size,
calculate your buffer size, open file, read at offset
filelengthminusbuffersize for buffer size, close file... I might want to
make smaller day.log files instead and join those at night to an archive
file/folder... in case you care to know what solution i chose...

i WONT try the negative offset ;( since I presume it will crash MC as did
the last command. Though knowing MC, it probably wont crash and wont work
nonetheless ;). MCv2.4.3 will not crash and will read that last <object>
without resorting to reading the whole file we'll hope!

Thanks for the tip it will come in handy if i use the day.log style log!!!
cheers
Xavier

> -----Original Message-----
> From: metacard-admin at lists.runrev.com
> [mailto:metacard-admin at lists.runrev.com]On Behalf Of shop
> Sent: Monday, April 22, 2002 15:27
> To: metacard at lists.runrev.com
> Subject: Re: Reading files backwards
>
>
> I have found that referring to files as URLs is a beautiful thing
> because it
> allows you to refer to a file as if it were a variable which means you can
> use all your chunk expressions on it.  Sooo, try
>
> put the last line of url "file:blabla.txt" into r
>
> The only exception I've found to my opening statement is that
> delete doesn't
> seem to work with URLs.  I.E. delete the last line of url
> "file:blabla.txt"
> returns an error.
>
> Rich
> Payne Sparkman Mfg.
> shop at paynesparkman.com
>
> ----- Original Message -----
> From: <xbury.cs at clearstream.com>
> To: <metacard at lists.runrev.com>
> Sent: Monday, April 22, 2002 7:54 AM
> Subject: Reading files backwards
>
>
> > Hi Gang,
> >
> > Got a problem which may help others if there is a solution...
> > I need to read the very last line from a file that's 3 - 20MBs large...
> > So I tried:
> >
> > open file blabla for reading
> > read from file blabla for -100
> > put the result into r
> > put it into x
> > close file blabla
> >
> > Unfortunately I never got an answer back, MC crashed...
> > No result, no error...
> >
> > I dont want to resort to external programs (tail.exe) to do this...
> > Does anyone have a standard scripted solution?
> >
> > Thanks in advance
> > Xavier
> >
> >
> >
> > Visit us at http://www.clearstream.com/_focus1.htm
> >
> > IMPORTANT MESSAGE
> >
> > Internet communications are not secure and therefore Clearstream
> International does not accept legal responsibility for the
> contents of this
> message.
> >
> > The information contained in this e-mail is confidential and may be
> legally privileged. It is intended solely for the addressee. If
> you are not
> the intended recipient, any disclosure, copying, distribution or
> any action
> taken or omitted to be taken in reliance on it, is prohibited and may be
> unlawful. Any views expressed in this e-mail are those of the individual
> sender, except where the sender specifically states them to be
> the views of
> Clearstream International or of any of its affiliates or subsidiaries.
> >
> > END OF DISCLAIMER
> > _______________________________________________
> > metacard mailing list
> > metacard at lists.runrev.com
> > http://lists.runrev.com/mailman/listinfo/metacard
>
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard
>




More information about the metacard mailing list