這是我到目前爲止創建關於您的諮詢:Perl腳本:如何實現某個進程已完成
#!/usr/bin/perl -w
use strict;
use CGI qw(:standard);
#some variables
my $message = "please wait, loading data...\n";
#First build the web page
print header;
print start_html('Hello World');
print "<H1>we need love, peace and harmony</H1>\n";
print "<p>$message</p>\n";
#Establish a pipeline between the bash and my script.
my $bash_command = '/love/peace/harmony/./lovepeace.bash';
open(my $pipe, '-|', $bash_command) or die $!;
while (my $line = <$pipe>){
# Do something with each line.
print "<p>$line</p>\n";
}
#when is the job done...?
print end_html;
當我打電話,在我的瀏覽器腳本特等,一切工作不錯:-)但有幾個問題仍在我的腦海裏:
當我打電話給這個網站時,它正忙於從管道中加載一些值。由於有大約10個值其相當快(2-4秒),但如果我將有超過100個值,用戶必須等待一段時間。由於我無法擁有進度條,因此我應該向用戶提供信息。
一樣:「正在加載數據,請稍候......」
當任務完成,此消息應該說:「作業已完成」或類似的東西。
•如何瞭解流程是否已完成?
•如果作業完成,我可以重新加載頁面嗎?
•有沒有用我自己的樣式表wihtin這與Perl CGI
問候,
JJ
請參閱[documentation](http://perldoc.perl.org/functions/open.html):關閉任何管道文件句柄會導致父進程等待子進程完成,並返回狀態值$?和$ {^ CHILD_ERROR_NATIVE}。 – ceving 2011-05-04 14:07:35