By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,776 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,776 IT Pros & Developers. It's quick & easy.

Getting console output

P: 4
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 "someAppThatGeneratesConsoleOutput.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.
Feb 13 '09 #1
Share this Question
Share on Google+
3 Replies

Expert 100+
P: 410
You may use reverse quotes to run the system command and capture the results into a variable and later insert it to Tk Textbox:
Expand|Select|Wrap|Line Numbers
  1. my  $TextBox= $fr->Scrolled( 'Text', '-scrollbars' => 'e', '-background' => 'yellow',       
  2.   )->pack( -fill => 'both', -expand => 1, -side => 'bottom' );
  4. my @res=`dir /w`; ##Pass your comand within reverse quotes
  6. $TextBox->insert('end',"@res");
Feb 15 '09 #2

Expert 2.5K+
P: 4,059
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};
Feb 15 '09 #3

P: 4
Ah Wonderful! :D Thanks a lot =)
Feb 15 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.