Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Capturing output with input

Reply
Thread Tools

Capturing output with input

 
 
gopala
Guest
Posts: n/a
 
      10-28-2007
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

 
Reply With Quote
 
 
 
 
Gabriel Genellina
Guest
Posts: n/a
 
      10-29-2007
En Sun, 28 Oct 2007 15:39:07 -0300, gopala <(E-Mail Removed)>
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

 
Reply With Quote
 
 
 
 
gopala
Guest
Posts: n/a
 
      10-29-2007
On Oct 29, 9:03 am, "Gabriel Genellina" <(E-Mail Removed)>
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Capturing global input? nomihn0 Python 4 12-10-2007 12:44 AM
capturing Input from a microphone Yannick C++ 2 06-09-2006 02:29 PM
Capturing output with simultaneous File handle input thomasjbs@gmail.com Perl Misc 1 07-02-2005 06:37 AM
pipe(), fork(), exec(), ... providing input to and capturing output of a child process Hoegje C++ 2 12-05-2003 04:03 PM
Capturing ASPX output from another page Rick Strahl [MVP] ASP .Net 1 07-09-2003 07:34 PM



Advertisments