Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old July 3rd, 2008, 01:01 PM
Newbie
 
Join Date: Jul 2008
Posts: 1
Default Redirecting the output of an exe file to a txt file

I am running an application on windows. I don't have the source code :(..
I need to capture the output of this exe file and redirect it into a file using my script. Can anybody help me with this? Can I use TK or IO Capture module for this?
Reply
  #2  
Old July 3rd, 2008, 04:23 PM
nithinpes's Avatar
Expert
 
Join Date: Dec 2007
Age: 24
Posts: 366
Default

If your exe application is directly displaying it's output to command window, use output redirection operator within system() command as in:
Expand|Select|Wrap|Line Numbers
  1. system("tool.exe >> result.txt");
  2.  
If your tool expects some user input, then you would need the display to appear both on command console as well as log file. Try using:

Expand|Select|Wrap|Line Numbers
  1. open(STDOUT, "| tee result.txt STDOUT");
  2. system("tool.exe >> result.txt");
  3. close (STDOUT) ;
  4.  
-Nithin
Reply
  #3  
Old July 4th, 2008, 06:16 AM
nithinpes's Avatar
Expert
 
Join Date: Dec 2007
Age: 24
Posts: 366
Default

Quote:
Originally Posted by nithinpes
If your exe application is directly displaying it's output to command window, use output redirection operator within system() command as in:
Expand|Select|Wrap|Line Numbers
  1. system("tool.exe >> result.txt");
  2.  
If your tool expects some user input, then you would need the display to appear both on command console as well as log file. Try using:

Expand|Select|Wrap|Line Numbers
  1. open(STDOUT, "| tee result.txt");
  2. system("tool.exe >> result.txt");
  3. close (STDOUT) ;
  4.  
-Nithin
Just a correction in the second code. It should be:

Expand|Select|Wrap|Line Numbers
  1. open(STDOUT, "| tee result.txt");
  2. system("tool.exe");
  3. close (STDOUT) ;
  4.  

Last edited by nithinpes; July 4th, 2008 at 06:20 AM. Reason: edited script
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles