Monks,

I have a CGI program that is used to produce custom reports from our firewall logs. These reports sometimes take 30-60 min to produce. I configured Apache so the browser won't timeout while creating the report. This program also uses some system utilities to create the report so it's not all Perl based. I would like a way to let the user know the status of the report being generated. I have read Merlyn's Webtechnique article, but I'm having a hard time trying to implement this into my program. I was thinking about trying to guess how long the script will take from the users values and keep refreshing this number. Does anyone have any suggestions? Here is a summary of the action script:
#!/usr/bin/perl -w use strict; # 'taint' in the import list is currently a no-op. See the documentat +ion use CGI::Carp 'fatalsToBrowser'; use CGI::Safe qw/:standard taint/; use Mail::Sender; my $summary = param( 'summary' ) || ''; my $num_sites = param( 'websites' ) || ''; my $ip = param( 'ip' ) || ''; ... my (@days,$string,$result,$sender,$src,$direct); my $dir = "/var/tmp"; my $header = "$dir/header"; my $output = "$dir/output"; # Delete the output file if it exist unlink $output; # Run the subroutines &check_email(); &display_page(); # Delete the output file once we are done unlink $output; exit; sub check_email { # Make sure the user enters a company email address. if ($email =~ /([.\w]+)(\@acme+\.com$)/) { &do_work(); } else { die "$email is not a valid email address. Please try again.\n"; } } sub do_work { # Copy the 1st line from the log files which is necessary for fwlog +sum open (IN,"$header") or die "can't open file $header: $!"; open (OUT,">$output") or die "can't open file $output: $!"; while (<IN>) { print OUT $_; } # Add each day to an array $string = "$month1" . "$year"; @days = ($day1 .. $day2); @days = map {$_ .= "$string"} @days; # add the month and year to ea +ch day if ($summary eq 'yes') { if ($direction eq 'inbound') { ... } } elsif ($direction eq 'outbound') { .... } } elsif ($summary eq 'no') { ... } elsif ($direction eq 'outbound') { ... } close (IN); close (OUT); my $fwlogsum = "/usr/local/bin/fwlogsum -ra -w -sc -bo -T -l $outpu +t -o /exported/web-usage/$report.html"; my $fwlogsum_sum = "/usr/local/bin/fwlogsum -ra -w -sc -bo -T -S -P + $num_sites -l $output -o /exported/web-usage/$report.html"; my $fwlogsum_sum_dns = "/usr/local/bin/fwlogsum -ra -w -sc -bo -C - +T -R -S -P $num_sites -l $output -o /exported/web-usage/$report.html" +; my $fwlogsum_dns = "/usr/local/bin/fwlogsum -ra -w -sc -bo -C -T -R + -l $output -o /exported/web-usage/$report.html"; if ($dns eq 'yes' && $summary eq 'yes') { $result = `$fwlogsum_sum_dns`; } elsif ($dns eq 'yes' && $summary eq 'no'){ $result = `$fwlogsum_dns`; } elsif ($dns eq 'no' && $summary eq 'yes'){ $result = `$fwlogsum_sum`; } else { $result = `$fwlogsum`; } #end else mail(); } sub mail { ... } sub display_page { my $message = shift; print header, start_html( "-title" => "Results Page"), p(" "), p( strong("Mail Sent Ok") ), end_html; }
Thanks,
Dru
Another satisfied monk.

In reply to Informing the User the Status of their Query by dru145

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.