On Thu, Oct 02, 2003 at 01:44:37AM -0000, PerlDiscuss - Perl Newsgroups and mailing 
lists wrote:
> Hi,
> 
> I have a CGI script that takes some time to finish searching the DB. In
> the meanwhile, how do I show that the job is being processed?
> 
> I tried just simple printing the same, but it wouldnt show up until the
> search is over. I tried using threads with the same result.

First, let me say I've never done this. That aside, there are a couple
ways I've heard of to do it. One is using fork(). The other, is just a
quick kludge which might work if security isn't an issue. That is to
put the DB query into a seperate .pl and execute it in the background
via a system call something like system("DB_Job.pl arg1 arg2... \&").
Have it (DB_Job.pl) dump the data into a temp file using something like
Data::Dumper. From a loop in your main script you would check the contents
of the temp file every second or so and print a generic status message
(ie. "searching db...") until the job is complete, when it then prints the
final search results.

Comments are welcome from more experienced parties.

-- 
=====================
 Shaun Fryer
=====================
 http://sourcery.ca/
 ph: 905-529-0591
=====================

Science is like sex: occasionally something useful
comes out of it, but that's not why we do it.
-: Richard Feynmann

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to