HI Perl Monks, Perl version : 5.16.3 Os: Windows 7 64 bit Tk :804.030 installed. For my testing i ve created a piece of code which actually logs in to my Wireless router , configures some value and comes out. For this i created a GUI inteface using Tk having few options which include a "Run" button and a text box ( to print the run time result). When user click on run button, our script starts configuring the wireless router as expected but its not sending the results to the text box of the GUI for successful completion of each test. i could see all the result at once after the entire test is completed. In the below coded this guy is not working as expected for me: $txt -> insert('end',"Executing Security Testcases...\n"); as its getting printed after the entire test is finished. Wondering if the property for button does not alllow realtime displaying in text box. Please help me to resolve this. NOte: i'm a beginner level perl user and google was helping me in writing the below code.

use Tk; use Net::FTP; use Tk::BrowseEntry; #use strict; #use warnings; #local $| = 1; use Tk::Button; use Net::Telnet (); #use File::Copy; $window = MainWindow->new; $window->title("Test WAR"); $window->configure(-background=>'gray79'); $window->geometry( "300x700" ); #$window->Label(-text => " Free Space:",-backg +round => 'gray79')->place(-x=>35,-y=>43); $window->Label(-text => " IP :",-background => + 'gray79')->place(-x=>35,-y=>20); $IP = $window->Entry(-width=>20, -background +=> 'light blue')->place(-x => 120,-y =>20); my $chk1 = $window ->Checkbutton(-activebac +kground => "gray79",-background => 'gray79',-text=>"Security Test",-v +ariable=>\$chkautoTRN)->place(-x =>100,-y =>60); my $chk1 = $window ->Checkbutton(-activebackgr +ound => "gray79",-background => 'gray79',-text=>"Connectivity",-varia +ble=>\$connectivity)->place(-x =>100,-y =>80); #my $chk1 = $window ->Checkbutton(-activebackg +round => "gray79",-background => 'gray79',-text=>"Good Write",-variab +le=>\$chkautoGW)->place(-x =>100,-y =>100); #my $chk1 = $window ->Checkbutton(-activebackg +round => "gray79",-background => 'gray79',-text=>"Flash ROM",-variabl +e=>\$chkautoFR)->place(-x =>100,-y =>120); #my $chk1 = $window ->Checkbutton(-activebackg +round => "gray79",-background => 'gray79',-text=>"Ethernet",-variable +=>\$chkautoE)->place(-x =>100,-y =>140); #my $chk1 = $window ->Checkbutton(-activebackg +round => "gray79",-background => 'gray79',-text=>"Audio",-variable=>\ +$chkautoA)->place(-x =>100,-y =>160); #my $chk1 = $window ->Checkbutton(-activebackg +round => "gray79",-background => 'gray79',-text=>"Micro SD",-variable +=>\$chkautoMSD)->place(-x =>100,-y =>180); #my $chk1 = $window ->Checkbutton(-activebackg +round => "gray79",-background => 'gray79',-text=>"Display",-variable= +>\$chkautoD)->place(-x =>100,-y =>200); #my $chk1 = $window ->Checkbutton(-activebackg +round => "gray79",-background => 'gray79',-text=>"Auto Cab",-variable +=>\$chkautoAC)->place(-x =>100,-y =>220); $window ->Button(-text => "Run", -command =>\& +push_button, -width=>10,-relief => 'groove',-activebackground=>blue,- +relief =>'raised')->place(-x => 50,-y =>600); $window ->Button(-text => "End", -command =>\& +close, -width=>10,-relief => 'groove',-activebackground=>red,-relief +=>'raised')->place(-x =>125,-y =>600);#-relief => 'groove','flat'|'gr +oove'|'raised'|'ridge'|'sunken'|'solid' #$window->Label(-text => "Results",-width=>10, +-background => 'gray79')->place(-x=>35,-y=>250); $txt = $window -> Text(-width=>30, -height=>20 +)->place(-x =>40,-y =>280); $count=1; MainLoop; sub push_button { $host = $IP -> get(); $port = "23"; $uid = "admin"; $pwd = "password123"; open $inputLog, ">in1.log"; $box = new Net::Telnet(); $box->open( Host => $host, Port => $port, ); $iLog = $box->input_log($inputLog); $flag = $box->login( Name => $uid, Password => $pwd, ); if ($chkautoTRN==1) { #sleep 4; $txt -> insert('end',"Executing Security Testcases...\n"); open(MYFILE,'security_profiles.txt'); while (<MYFILE>) { chomp; $x=$_; $box->print($x); $box->waitfor(Match=>'/# $/i',Timeout=>25); #Match=>'/# $/i', #sleep 12; } #$box->close; #system ("cat in.log"); close MYFILE; } if($connectivity==1) { while($count<=100) { system('netsh wlan disconnect'); sleep 2; system('netsh wlan connect name=720wlan0vap7'); #print "wifi connected\n"; sleep 15; $box->cmd('get association station'); $result=$box->lastline; system('netsh wlan disconnect'); #print "wifi disconnected\n"; sleep 15; $txt -> insert('end',"The client $result got connected $count time +\n"); $count++; } } $box->cmd('get association station'); $result=$box->lastline; $txt -> insert('end',"$result\n"); $box->close; } sub close { exit(); }


In reply to Related with Perl Tk by VpK

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.