Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: Win32 GUI freeze

by ckant8 (Acolyte)
on Feb 19, 2013 at 04:15 UTC ( #1019436=note: print w/ replies, xml ) Need Help??


in reply to Re: Win32 GUI freeze
in thread Win32 GUI freeze

use thread; use Parallel::ForkManager; use Data::Dumper; use Net::Telnet; use Win32::API; use Win32::GUI(); $main = Win32::GUI::Window->new( -name => 'Main', -width => 500, -height => 900, -text => 'Perl', -minsize => 500, 900, ); my $loadImage = new Win32::API ('user32', 'LoadImage', 'N','N','I','I','I','I','N') or die 'cannot find LoadImage function'; my $waitCursor = $loadImage->Call(0, 32514, 2, 0, 0, 0x8040); my $font = Win32::GUI::Font->new( -name => "Comic Sans MS", -size => 8,); $main->AddLabel(-text => "Welcome ", -pos => 10, 10 , -size => 190, 125 ,); $main->AddLabel(-text => "Enter Host Name / IP : ", -pos => 10, 33 , -size => 190, 125 , ); my $t= $main->AddTextfield( -name => 'tfResults', -text => "hostname", -pos => 125, 30 , -size => 100, 25 , ); my $my_but = $main->AddButton(-text => "Submit",-name => 'btQuery', -pos => 235, 30 ,-size => 50, 25 ,); $main->Show(); Win32::GUI::Dialog(); sub btQuery_Click { $main-> DoEvents(); $txt1=$t->Text; if ($txt1) { my $txt1=$t->Text; if($txt1=~/a-zA-Z0-9+/) { #CHECKING WINDOWS OR UNIX HOST BY CALLING BELOW FUNCTION $oldCursor = Win32::GUI::SetCursor($waitCursor); #show hourglass ... print "\nConnecting to : $txt1"; &host1($txt1); if($hosttype=~/Unix/) { $t->ReadOnly(1); $my_but->Disable(); &unix_host; } elsif($hosttype=~/Windows/) { $t->ReadOnly(1); $my_but->Disable(); &win_host; } elsif($hosttype=~/unknowhost/) { $main->AddLabel(-text => "", -pos => 10, 200 , -size => 500, 500 ,); $main->AddLabel(-text => "Unable to connect host. Please check the host name/ip.", -pos => 10, 200 , -size => 500, 950 ,-font => $font, -foreground => 0, 0,250,); print "\nUnknow host. Please check the host name/ip."; last; } # Connecting to Unix host sub unix_host { my $txt1=$t->Text; $main->AddLabel(-text => "", -pos => 0, 200 , -size => 500, 900 ,); $main->AddLabel(-text => "Please wait.....logining to host. ", -pos => 10, 200 , -size => 500, 500 ,); $telnet = new Net::Telnet ( Timeout=>1800, Errmode=>'die', input_log=>'input.log',output_log=>'output.log',Dump_Log=>'dump.log',Option_log=>'option.log'); $telopt_ttype_ok = ''; $telnet->option_callback(\&opt_callback); $telnet->option_accept(Do=>Net::Telnet->TELOPT_TTYPE); $telnet->suboption_callback(\&subopt_callback); chomp $txt1; $telnet->open($txt1); my $oldCursor = Win32::GUI::SetCursor($waitCursor); #show hourglass ... $telnet->waitfor('/login: $/i'); $telnet->print('root'); $telnet->waitfor('/Password: $/i'); $telnet->print('dangerous'); $telnet->waitfor('/# $/i'); print "\nConnected to Unix host :$txt1 "; print FILE "\n@time1:Connected to Unix host: $txt1"; $main->AddLabel(-text => "Connected to Unix host. ", -pos => 10, 500 , -size => 500, 500 ,); #print "\nSetting symcli and adios path on host."; #my $PATH = '/usr/symcli/bin:/usr/adios'; #$telnet->print("PATH=$PATH"); #PATH=$PATH:/data/myscripts #$telnet->print("PATH=$PATH:/usr/symcli/bin:/usr/adios"); #$telnet->print("export PATH"); #$telnet->waitfor('/# $/i'); Win32::GUI::SetCursor($oldCursor); #show previous arrow cursor again $check1=$main->AddButton(-name => "Unix_Check",-text => "Check version",-pos => 55, 70 ,); $main->AddLabel(-text => " Enter custom cmd:",-pos => 10, 100 ,-size => 250, 125 ,); $t1= $main->AddTextfield(-name => 'tfResults2',-text => "",-pos => 130, 100 ,-size => 100, 25 ,); $submit=$main->AddButton(-text => "Submit",-name => 'Unix_submit',-pos => 250, 100 ,-size => 50, 25 ,); sub Unix_Check_Click { } sub Unix_submit_Click { } } } } }


Comment on Re^2: Win32 GUI freeze
Re^3: Win32 GUI freeze
by dasgar (Deacon) on Feb 19, 2013 at 06:04 UTC

    When you post code, you need to put it inside <code></code> tags, which makes it much easier for others to read.

    I've posted your code reformatted in a more easier to read format below. However, while reformatting your code, I noticed that it looks like there are some issues with curly brackets. There are some areas that are missing the closing curly brackets and then there are extra curly brackets at the end of your code.

      Sorry for the trouble.. i have just added a snap of my code.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019436]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2014-11-22 21:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (125 votes), past polls