Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6333765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:31:36+00:00 2026-05-24T18:31:36+00:00

#!/usr/local/bin/perl use Tk; # Main Window $mw = new MainWindow; $label = $mw ->

  • 0
#!/usr/local/bin/perl
use Tk;
# Main Window
$mw = new MainWindow;
$label = $mw -> Label(-text=>"Hello folks") -> pack();
$button = $mw -> Button(-text => "Click here to Flush rules",
                -command =>\&flush) -> pack();
MainLoop;

sub flush {
$mw->messageBox(-message=>"Initiating flushing.. click on OK button");
system ("iptables -L");
system ("iptables -F");
system ("iptables -L");
}

I made this code and what it does is that when a user click on the Button a message box appears

enter image description here

Then when I click on OK button it calls the subroutine flush and then the output is shown on terminal like this:

enter image description here

I want it to be appear on the same message box. How can I do it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:31:37+00:00Added an answer on May 24, 2026 at 6:31 pm

    I have got the answer of this question at perlmonks.

    The link of the post at perlmonks is-> http://www.perlmonks.org/index.pl?node_id=920414

    #!/usr/bin/perl
    use warnings;
    use strict;
    use Tk;
    
    # Main Window
    my $mw = new MainWindow;
    $mw->geometry('+100+100');
    
    my $label = $mw -> Label(-text=>"Hello folks") -> pack();
    my $button = $mw -> Button(-text => "Click here to Flush rules",
                    -command =>\&flush) -> pack();
    MainLoop;
    
    
    sub flush {
    $mw->messageBox(-message=>"Initiating flushing.. click on OK button");
    # the script hangs here, until the messagebox OK button is pressed.
    
    my $text = $mw->Scrolled('Text')->pack();
    
    #my $out1 =  `iptables -L`;
    my $out1 =  `ls -la`;
    $text->insert('end',"$out1\n");
    $text->see('end');
    
    #my $out2 =  `iptables -F`;
    my $out2 =  `dir`;
    $text->insert('end',"$out2\n");
    $text->see('end');
    
    #my $out3 =  `iptables -L`;
    my $out3 =  `ps auxww`;
    $text->insert('end',"$out3\n");
    $text->see('end');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#!/usr/local/bin/perl use Tk; # Main Window $mw = new MainWindow; $label = $mw ->
#!/usr/local/bin/perl use warnings; use 5.012; use Text::Document; use Text::DocumentCollection; my $c = Text::DocumentCollection->new( file
#!/usr/bin/env perl use warnings; use strict; use 5.012; use XML::LibXML::Reader; my $reader = XML::LibXML::Reader->new(
How can I use __DATA__ twice? #!/usr/local/bin/perl use warnings; use 5.012; while ( <DATA>
If I do this #!/usr/local/bin/perl use warnings; use 5.014; use LWP::UserAgent; my $ua =
#!/usr/local/bin/perl use warnings; use 5.014; use Mojolicious::Lite; use DBI; # ... get '/choose' =>
#!/usr/local/bin/perl use strict; use warnings; system(cd $PATH /usr/bin/sftp mysite.com <<!EOF put sample.txt bye !EPF);
I am using the following script: #!/usr/local/bin/perl -wT use strict; use warnings; print Content-type:
I am executing a diff command in perl . my @lines = `/usr/local/bin/diff -udr
When I write #!/usr/bin/perl -w use strict; while( <DATA> ) { print \n-------------------------\n\n; print;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.