Display progress or partial results in browser window

Display progress or partial results in browser window

am 25.11.2005 21:09:57 von bruce

Hi.

I've written an agent (using Mech) to search for audiobooks and eAudio
books in several libraries. As this takes quite a while, I'd like to be
able to make the browser display progress results.

I can launch the agent and then launch another script in a browser that
reads periodically from a file written by the agent. But this seems like
an awkward solution.

I have very little experience with interprocess control, but I thought I
should be able to launch the spider script to run in the background with
a system call and then redirect to a perl script that will refresh
periodically and display the books (or number of books) retrieved in a
browser window. But I haven't been get the browser to do anything until
the child process is finished.

There is a script published in Linux magazine by Randal Schwartz
http://www.linux-mag.com/content/view/1122/2222/ that works along these
lines, but it doesn't work on my Win32 machine. (Its example of a long
process is "exec traceroute" -- the only change I made was to make this
Win32's "exec tracert" )

I've tried to find the solution in Learning Perl, the Perl Cookbook and
Perl FAQ, but the material dealing with IPC seems geared to running from
the command line.

Is there a basic tutorial that covers forking thing somewhere?

Thx,

Bruce

--
Bruce McKenzie
http://www.2MinuteExplainer.com

Re: Display progress or partial results in browser window

am 25.11.2005 21:33:28 von sebbaz

On 25/11/05, Bruce McKenzie wrote:
> Hi.
>
> I've written an agent (using Mech) to search for audiobooks and eAudio
> books in several libraries. As this takes quite a while, I'd like to be
> able to make the browser display progress results.
>
> I can launch the agent and then launch another script in a browser that
> reads periodically from a file written by the agent. But this seems like
> an awkward solution.

Why not just have the agent print to STDOUT or STDERR?

> I have very little experience with interprocess control, but I thought I
> should be able to launch the spider script to run in the background with
> a system call and then redirect to a perl script that will refresh
> periodically and display the books (or number of books) retrieved in a
> browser window. But I haven't been get the browser to do anything until
> the child process is finished.

That may be a feature of the browser.
Try outputting a lot of blank lines to get it to display.
Have you set autoflush on and/or disabled output buffering?

> There is a script published in Linux magazine by Randal Schwartz
> http://www.linux-mag.com/content/view/1122/2222/ that works along these
> lines, but it doesn't work on my Win32 machine. (Its example of a long
> process is "exec traceroute" -- the only change I made was to make this
> Win32's "exec tracert" )
>
> I've tried to find the solution in Learning Perl, the Perl Cookbook and
> Perl FAQ, but the material dealing with IPC seems geared to running from
> the command line.
>
> Is there a basic tutorial that covers forking thing somewhere?
>
> Thx,
>
> Bruce
>
> --
> Bruce McKenzie
> http://www.2MinuteExplainer.com
>

Re: Display progress or partial results in browser window

am 27.11.2005 14:26:31 von philippe.bruhat

Le vendredi 25 novembre 2005 =E0 15:09, Bruce McKenzie =E9crivait:
> Hi.
>=20
> I've written an agent (using Mech) to search for audiobooks and eAudio=20
> books in several libraries. As this takes quite a while, I'd like to be=
=20
> able to make the browser display progress results.
>=20
> I can launch the agent and then launch another script in a browser that=
=20
> reads periodically from a file written by the agent. But this seems lik=
e=20
> an awkward solution.

You could also use the callback argument to LWP::UserAgent's request() me=
thod
to track progress.

--=20
Philippe "BooK" Bruhat

Treat those you outrank well... you never know when they will outrank yo=
u.
(Moral from Groo #7 (Ima=
ge))