How can I continuously inform the user of progress from a Perl CGI script?

前端 未结 6 660
一整个雨季
一整个雨季 2021-01-13 12:04

I have this Perl script sitting in the cgi-bin folder of my Apache server:

#!/usr/bin/perl 
use strict;
use warnings;

$| = 1;

print \"Content-type: text/ht         


        
6条回答
  •  借酒劲吻你
    2021-01-13 12:42

    To see if your script is working, try using a command line tool to avoid any confusion with your browser. curl, for example, will output as soon as it receives data.

    If what you are doing is for an important purpose, I wouldn't use your current approach, though. If the script takes a long time to run, fork it off into the background (info here) and update a file or database with progress. You can then use an auto-refreshing (JavaScript or META-REFRESH) iFrame to display the progress. You could also use AJAX, but that is a bit more involved.

提交回复
热议问题