Steve,
Thanks for that, but I already know that tail -f doesn't finish. That's
sort of the point.
What I want is a long running (maybe neverending) stream to come back from
the popen call.
I would have thought that doing a readline on an ever growing file would
indeed do as it says, read one line and then return it to the script.
The file in question is a log file of a web-server, and even when new data
is added to the file, readline still doesn't return.
Anyone else have any thoughts?
tia
Phil
[EMAIL PROTECTED]
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "Phil Harris" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
Sent: Thursday, July 05, 2001 5:57 PM
Subject: RE: popen usage
> Readline is not SUPPOSED to finish! Here is what the manual says about
> tail -f regarding this:
>
> the tail command does not terminate after the last
> specified unit of the input file has been copied, but continues to read
> and copy
> additional units from the input file as they become available.
>
> The idea is that it NEVER terminates, but shows you basically everything
> from the point specified on.
>
> Another portion of the man page is clearer:
>
>
> 4. To follow the growth of a file, enter:
> tail -f accounts
>
> This displays the last 10 lines of the accounts file. The tail
command
> continues to display lines as they are added to the accounts file.
> The
> display continues until you press the Ctrl-C key sequence to stop it.
>
> Steve
>
>
> -- Original Message --
>
> >All,
> >
> >I have a script that uses popen to start an external process (tail -f)
> and
> >allow me to read the results:
> >
> >1: stdin=os.popen('tail -f somefile')
> >2: logline=re.compile('(.*?).*?- - \[(.*?)\] "(.*?) (.*?)" (.*?) (.*?)
> >"(.*?)" "(.*?)".*')
> >3: a=stdin.readline()
> >4: print a
> >5: while a:
> >6: g=logline.search(a)
> >7: if not g: continue
> >
> >The problem is that it gets to line 3 and sits waiting for the readline
> to
> >finish, which as far as I can see it never does.
> >
> >Any ideas.
> >
> >Phil
> >
> >
> >
> >
> >_______________________________________________
> >ActivePython mailing list
> >[EMAIL PROTECTED]
> >http://listserv.ActiveState.com/mailman/listinfo/activepython
> >
>
>
>
> _______________________________________________
> ActivePython mailing list
> [EMAIL PROTECTED]
> http://listserv.ActiveState.com/mailman/listinfo/activepython
_______________________________________________
ActivePython mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/activepython