Connecting Tech Pros Worldwide Help | Site Map

Redirecting the output of an exe file to a txt file

  #1  
Old July 3rd, 2008, 01:01 PM
Newbie
 
Join Date: Jul 2008
Posts: 1
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?
  #2  
Old July 3rd, 2008, 04:23 PM
nithinpes's Avatar
Expert
 
Join Date: Dec 2007
Posts: 400
Provided Answers: 1

re: Redirecting the output of an exe file to a txt file


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
  #3  
Old July 4th, 2008, 06:16 AM
nithinpes's Avatar
Expert
 
Join Date: Dec 2007
Posts: 400
Provided Answers: 1

re: Redirecting the output of an exe file to a txt file


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Script modification of ISA access rules johanot answers 0 October 12th, 2008 05:21 PM
stream io in c Ron Ford answers 41 August 5th, 2008 07:05 PM
Redirection troubles Edwin G. Castro answers 4 November 15th, 2005 12:22 PM
Win32::Process - gunzip and output Paolo answers 2 October 5th, 2005 09:53 PM