Connecting Tech Pros Worldwide Help | Site Map

Redirecting the output of an exe file to a txt file

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 3rd, 2008, 12: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, 03:23 PM
nithinpes's Avatar
Expert
 
Join Date: Dec 2007
Posts: 383
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, 05:16 AM
nithinpes's Avatar
Expert
 
Join Date: Dec 2007
Posts: 383
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 05:20 AM. Reason: edited script
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search


Popular Articles

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 220,989 network members.