473,396 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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?
Jul 3 '08 #1
2 6864
nithinpes
410 Expert 256MB
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
410 Expert 256MB
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

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

Similar topics

2
by: Birch | last post by:
I have a python script that uses the print function throughout, and as well uses calls to os.system() to spawn DOS commandline executables. My issue is that I redirect all of the output from this...
0
by: John M. Lembo | last post by:
I am using Perl to parse a text file and output to another file. The text file has data on Unix virtual memory (vmstat) and I want to delete lines that I don't want and output lines that I want to...
1
by: andy.t.chou | last post by:
I need to be able to have a hidden field (signiture) with each output html file generated. # (Get the first and last name from the html form) $first_name = $q->param('FirstN'); $last_name =...
2
by: Oleg Ogurok | last post by:
Hi all, On my web page, I have a <OBJECT DATA="mydatafile.ica" ...> which loads Citrix ICA web client. The problem is that I want to generate the mydatafile.ica on the fly (e.g. based on...
1
by: Gurikar | last post by:
How to redirect information to file usinf cerr or clog. Regards
2
by: jerry | last post by:
Using VB.net standard 2003. While in development environment can create process to execute an external EXE program and redirect output to "file.txt" using System.Diagnostic.Process.Start. If I...
6
by: wxPythoner | last post by:
Hello! I have trouble understanding something in this code snippet: class TextReader: """Print and number lines in a text file.""" def __init__(self, file): self.file = file
4
by: standerby | last post by:
I am writing a XML file suing XElement. How can I output a file like the following? I got an exception if if I use ':' in the element name or attribute name. Thanks, <?xml version="1.0"...
2
by: xtremebass | last post by:
Hi Bytes, in Linux , is it possible to redirect Mysql table output to a file in Linux. i tried it, shows error , but output has displayed in linux prompt when no redirection of file has given(say...
1
by: perhapscwk | last post by:
$pdf->Cell(10,7,'test test test test test',1,0,'L'); Let say if i draw a table like above, since the string are longer than the width as i set (10), then some words will display out of the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.