Y
Yohan N. Leder
Hi,
Newbie in Perl and don't know how to do with this piece of script. I
would like it redirects to mainboard.cgi without waiting for long forked
process to be completed. Is it possible ? Knowing that in the real
script the storit sub does a GET to a remote counter script which
generates a log file.
#!/usr/bin/perl -w
use strict;
# normally use CGI, but just a quick test script here
print "CONTENT-TYPE: text/html; Charset=UTF-8\n\n";
# ... here, some *quick* treatments (less than 10 seconds)...
defined(my $pid = fork) or die "cannot fork : $!";
unless ($pid) {
# storit being a *long* process (say 1 or 2mn) without any print
storit();
exit 0;
}
# ... here, some checking about previous treatment
print "Successfull treatment ! Redirection in 4 secondes...";
print "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"4; URL=mainboard.cgi\">";
exit 0;
sub storit {
# simulate a long process (until 3mn in reality)
for (my $idx=1;$idx<10;$idx++) {
sleep 1;
}
}
And with this mainboard.cgi :
#!/usr/bin/perl -wT
use strict;
print "CONTENT-TYPE: text/html; Charset=UTF-8\n\n";
print "... main board ...";
exit 0;
Yohan N. Leder
Newbie in Perl and don't know how to do with this piece of script. I
would like it redirects to mainboard.cgi without waiting for long forked
process to be completed. Is it possible ? Knowing that in the real
script the storit sub does a GET to a remote counter script which
generates a log file.
#!/usr/bin/perl -w
use strict;
# normally use CGI, but just a quick test script here
print "CONTENT-TYPE: text/html; Charset=UTF-8\n\n";
# ... here, some *quick* treatments (less than 10 seconds)...
defined(my $pid = fork) or die "cannot fork : $!";
unless ($pid) {
# storit being a *long* process (say 1 or 2mn) without any print
storit();
exit 0;
}
# ... here, some checking about previous treatment
print "Successfull treatment ! Redirection in 4 secondes...";
print "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"4; URL=mainboard.cgi\">";
exit 0;
sub storit {
# simulate a long process (until 3mn in reality)
for (my $idx=1;$idx<10;$idx++) {
sleep 1;
}
}
And with this mainboard.cgi :
#!/usr/bin/perl -wT
use strict;
print "CONTENT-TYPE: text/html; Charset=UTF-8\n\n";
print "... main board ...";
exit 0;
Yohan N. Leder