sub sub1 { if($btn->cget(-text) eq 'Connect'){ $go = 1; $btn->configure(-text=> 'Stop'); $msg = 1; lstmsg(1); } else{ $go = 0; $btn->configure(-text=> 'Connect'); } } sub lstmsg{ if($msg == 1){ $lstbx->insert('end',"Connecting... Asking for Password..."); #$lstbx->insert('end', "sftp connected $user $server"); } if($msg == 2){ print "huh\n"; $lstbx->insert('end', "sftp connected $user $server"); goto AFTER; } } sub sftp{ $|++; #now go into a waiting loop, where you wait for $go to be 1. when +$go = 1, the sftp will keep sending the file. #the only way to break out is to set $die=1 while(1){ if($die == 1){ goto END }; if ( $go == 1 ){ my $seconds = 120; my %args = (host=>$server, user=>$user, timeout=>$seconds) +; my $sftp = Net::SFTP::Foreign->new(%args); print "What\n"; $msg = 2; if($msg == 2){lstmsg(1)}; AFTER: print "happy\n"; for(;;){ $sftp->put("$local", "$remote"); print "fake file being sent\n"; sleep 2; if($go == 0){last}; if($die == 1){ goto END }; } undef $sftp; #close current sftp $go = 0; #turn off self before returning } else { sleep 1 } # sleep if $go == 0 } END: print "sftp stopped thread ending\n"; } sub clean_exit{ my @running_threads = threads->list; if (scalar(@running_threads) < 1){print "\nFinished\n";exit} else{ $die = 1; $thr->join; exit; } }
In reply to Inserting Text into Listbox from a Thread
by deadpickle
in thread Looping File transfer using SFTP in TK
by deadpickle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |