473,394 Members | 1,697 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,394 software developers and data experts.

Capturing output with input

Hi, I am pretty new to python but i do have experience with c++. As a
part of learning exercise i wrote a python script to insert
beautifying comments(with name, problem...) to our lab program source
files (c language).

The script is working for most of the cases. The problem is i also
need to append the test output of the lab programs to the
corresponding source files(again the output should be added as a
beautified comment). The lab programs are interactive and very
different from each other. Currently in the script, i am prompting the
user(me!) to manually enter the output of the program which it to be
inserted. I want to eliminate this tedious step.

for eg i want "python commenter.py lab1.c" to initially prepend
comments with my name... and then spawn lab1.exe , capture its output
and append it with comments to lab1_com.c

My initial attempts of using spawn.. , exec.. pipe.. failed since they
can't capture the std input and std output continuously.
The lab1.exe will be something like

Enter 2 nos
2 3
The sum is 5

Now i should be able to capture all these.
Is this possible ? If so please do give me some hints on how to
achieve this.

Cheers,
Gopala Krishna

Oct 28 '07 #1
2 1563
En Sun, 28 Oct 2007 15:39:07 -0300, gopala <kr*********@gmail.com>
escribi�:
My initial attempts of using spawn.. , exec.. pipe.. failed since they
can't capture the std input and std output continuously.
The lab1.exe will be something like

Enter 2 nos
2 3
The sum is 5

Now i should be able to capture all these.
Is this possible ? If so please do give me some hints on how to
achieve this.
On Linux, use the "script" command.
On Windows, select the region to copy using the mouse and paste it onto a
notepad file.
I don't think Python would help here.

--
Gabriel Genellina

Oct 29 '07 #2
On Oct 29, 9:03 am, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
wrote:
On Linux, use the "script" command.
On Windows, select the region to copy using the mouse and paste it onto a
notepad file.
I don't think Python would help here.
Thanks :-)
Now i just do os.system(exeFile) and i can easily copy the output
from terminal using mouse selection.

Oct 29 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Moosebumps | last post by:
I have a large set of Python scripts that interface with command line utilities (primarily Perforce). I am currently capturing ALL the text output in order to get results and such. I am using the...
2
by: Hoegje | last post by:
I am writing a C++ program, which should create a sub- process to start a telnet session to another server. Then it should login to that server (on the telnet login) and execute one or more...
1
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
4
by: PJ | last post by:
I would like to capture a request stream before the request has been completely sent to the server for the sake of saving the bytes of a posted file to disk. I have written httpmodules before, but...
10
by: Andrew | last post by:
Hi, I have a messagebox that pops up due to an event. I did it in javascript. ie. alert("Time's up. Assessment Ended"); I want to capture the OK and Cancel events of this alert messagebox. My...
1
by: Ivan | last post by:
Hello. I’m trying to capture standard output of the other process which is launched from my win app. I tried to do it with freopen function which captured content of the printf functions, but...
6
by: Ed Leafe | last post by:
I've been approached by a local business that has been advised that they need to start capturing and archiving their instant messaging in order to comply with Sarbanes-Oxley. The company is largely...
0
by: Buglish | last post by:
Hi, Task : -Capture a HTML table with use of regular expression from a text string buffer(entire document). –Pass it to another function to create a multi dimension array out of it. - Pass it...
4
by: csandbach | last post by:
Hi, I'm new to PHP, im used to coding in asp, so please bare with me. What i would like is to output the result to a text file <?php $_ip = $_SERVER; echo "<b>Enter the IP or the domain name...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.