나는 리눅스 박스에서 perl을 사용하고 있으며, IP 주소 192.168에서 로컬 네 트워크에 pc (리눅스 박스)와 라우터/dsl-thingy라는 2 개의 장치가있다. .1.1 & 192.168.1.2 그리고 아래의 코드와 함께 8 개의 다른 none none 디바이스의 테스트와 같은 ping의 진행 상황을 나열하거나 보여 주려고하지만, StatusLabel을 업데이트하는 데 문제가 있습니다.Perl의 쓰레드에서 라벨 업데이트하기
필요한 경우for($i=1;$i<=10;++$i) { # --- $i<$VarClients --- 254
my $thr_List = ("ping$i");
$thr_List = threads->create(\&pingingthreads, "$i");
}
sub pingingthreads{
my @pingpong = ping("$localAddress$i", '-c 1', '-i .2'); # -i may not count for much?
print "Pinging: $localAddress$i\n"; # output goes from address1 - address10 ok
$StatusLabel = "Pinging: $localAddress$i"; # only the last responding one(device) seems to be shown in my statuslabel?!
$val = ($val + 10); # 0.392156863
print "$val\% done...\n"; # goes to 100% for me ok
# $indicatorbar->value($val); # I have a ProgressBar and it gets stuck on 20% also
if ($val == 100){$val = 0;
} # reset after scanning
# then after the last ping, update the statusLable:
#my @ParamList = ('something', 'testing', 7, 8, 9);
#$thr5 = threads->create(\&updateStatusLable, @ParamList); # starting a thread within a thread ???
# ping response text...
for(@pingpong) { # need to do something for none responding clients & any time laps/ping latency..., or *** ???
$pong=$_;
chop ($pong); # Get rid of the trailling \n ??
if ($pong =~ m/1 packets transmitted, 1 received, 0% packet loss/) {
push(@boxs, "$localAddress$i");
} else{
# see the other lines from the ping's output
# print "$pong\n";
}
}
}
# For $localAddress$i icmp_seq=1 Destination Host Unreachable ???
--------------------- # StatusBar/progress label & bar ----------------
my $sb = $main->StatusBar();
$sb->addLabel(-textvariable => \$StatusLabel,
-relief => 'flat',
-font => $font,
-foreground => "$statusbartextColour",
);
my $indicatorbar = $sb->ProgressBar(-padx=>2, -pady=>2, -borderwidth=>2,
-troughcolor=>"$Colour2",
-colors=>[ 0, "$indicatorcolour" ],
-length=>106,
-relief => 'flat',
-value => "$val",
)->pack;
# $val = 0;
# $indicatorbar->value($val);
=====================================
my $StatusLabel :shared =();
my $val :shared = (0); # var for progress bar value
나는 (http://cid-99cdb89630050fff.office.live.com/browse.aspx/.Public) 여기 내 전체 코드를 업로드 그것 Boxy.zip에서 ...
안녕하세요. SO는 코드 팩토리가 아닙니다. 구체적인 질문을해야하며 구체적인 답변을 얻을 수 있습니다. – musiKk
위의 경우 옳지 않다면 죄송합니다, 내 질문에 달리 다 ... Perl 스레드에서 레이블을 어떻게 업데이트합니까. 나는 위의 그림을 사용하여 내가 어디에 있는지를 보여주고있다. – Carpenter