Getting console output

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EDPB
    New Member
    • Feb 2009
    • 4

    Getting console output

    Hi again!

    I need some help \ pointers on how to get the output generated in a console after you run a system command into a text widget (Perl Tk). I feel rather confident that I could get the data put into the widget if I could actually GET the data to begin with, but I can't seem to get this done :(

    e.g. system "someAppThatGen eratesConsoleOu tput.exe" -> get the output that is generated from this..

    Can't really explain any better, hope you understand :) Seen this done before (cross linux\windows with a simple method..) But I don't have that code anymore and I cant seem to remember how.
  • nithinpes
    Recognized Expert Contributor
    • Dec 2007
    • 410

    #2
    You may use reverse quotes to run the system command and capture the results into a variable and later insert it to Tk Textbox:
    Code:
    my  $TextBox= $fr->Scrolled( 'Text', '-scrollbars' => 'e', '-background' => 'yellow',       
      )->pack( -fill => 'both', -expand => 1, -side => 'bottom' );
    
    my @res=`dir /w`; ##Pass your comand within reverse quotes
    
    $TextBox->insert('end',"@res");

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      You can also use what I think is a more readable quoting operator that does the same thing as the backtiks:

      my @res= qx{dir /w};

      Comment

      • EDPB
        New Member
        • Feb 2009
        • 4

        #4
        Ah Wonderful! :D Thanks a lot =)

        Comment

        Working...