I have the following code which pings some wireless access points. Im still writing it but Im looking for a way to update the text as each access point is pinged instead of after its done pinging them all. Any help is appreciated.
#!/usr/bin/perl
use Net::Ping;
use Tk;
use Tk::Dialog;
my $mw;
my $shift;
my $port;
my @Addr=( 1 ... 55 );
my $statbar;
$mw = MainWindow->new;
$mw->title("AP ping");
$mw->geometry("203x595");
$mw->Label(-text => 'Choose Access Point to Ping')->place(-x => 5, -y
+=> 5);
$statBar = $mw->Label(-text => '',
-font => [-family => 'Lucida Console
+', -size => 8],
-width => 28,
-relief => 'groove')->place(-x => 0, -
+y => 575);
$mw->Button(-text => "Get Status",
-relief => 'groove',
-command => sub { $statBar->configure(-text => "pinging $h
+ost");
if ( $host eq "All" ) { \&mstat($_) for
+( 1 .. scalar(@Addr)) }
else { \&mstat($host); } })->place(-x =>
+ 60, -y => 70);
$mw->Button(-text => "Exit",
-relief => 'groove',
-command => sub { exit })->place(-x => 172, -y => 70);
my $tagOM = $mw->Optionmenu(-variable => \$host,
-options => [ '', 'All', @Addr ],
-width => 25,
-relief => 'groove',
-command => sub {})->place(-x => 5, -y => 30
+);
my $statLog = $mw->Scrolled("Text", -scrollbars => 'e', -height => 30,
+ width=> 25)->place(-x => 0, -y => 130);
MainLoop;
#############
sub mstat
#############
{
$ap = shift;
my $host = sprintf ("192.9.210.1%02d", $ap);
my $p = Net::Ping->new();
if ( $p->ping($host))
{
$statLog->insert('end', "AP $host is up\n");
#$statBar->configure(-text => "pinging $host is up");
}
else
{
$statLog->insert('end', "AP $host is down\n");
#$statBar->configure(-text => "AP $host is down")
}
$p->close();
}
Ted
--
"That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
--Ralph Waldo Emerson