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

Redirecting the output of an exe file to a txt file

P: 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?
Jul 3 '08 #1
Share this Question
Share on Google+
2 Replies


nithinpes
Expert 100+
P: 410
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
Jul 3 '08 #2

nithinpes
Expert 100+
P: 410
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.  
Jul 4 '08 #3

Post your reply

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