473,668 Members | 2,446 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1572
En Sun, 28 Oct 2007 15:39:07 -0300, gopala <kr*********@gm ail.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.a r>
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(exeFi le) 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
2131
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 popen functions to get the stdout, stderr streams. However, some of the operations take a really long time (copying large files over the network). If you run Perforce directly (or through os.system, which doesn't return text output), it shows...
2
4354
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 command(s) on the remote server. The C++ program provides all the input for this process (username, password, servername, commands, ...) and should capture all the output returned by the telnet session process inside some variable. How can this be...
1
5378
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 application (VB.NET) will start a process, redirect its stdout and capture that process' output, displaying it in a window. I've written a component for this, and a test application for the component. It allows me to specify a command to execute,...
4
3211
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 (correct me if I am wrong) it seems that by the ProcessRequest event, the Request has been completely sent and aspnet_wp has used it to hydrate the httpcontext instance. Is there a .net way of capturing an http request as it comes in to the...
10
6007
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 code is in C#/ASP.NET. TIA. Andrew.
1
1275
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 not the output of the other processes (even if it used printf function and launched with system function). How can I perform my task? How should I run other processes?
6
2261
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 PC, but has a significant number of Macs running OS X, too. Googling around quickly turns up IM Grabber for the PC, which would seem to be just what they need. But there is no equivalent to be found for OS X. So if anyone knows of any such...
0
1601
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 to another function to build it into a RTF table. -Then return it back to the regular expression to replace the search result. Difficulty: -The regular expression doesn’t pass the back referenced table fields to the next function.
4
4664
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 of the server that you are trying to route.</b><br>"; echo "<form method='post' action='?do=route'><input type='text' name='domain' class='input_login' value='$_ip'>&nbsp;<input type='submit' value='Route' class='input_login'></form>"; if($_GET ==...
0
8371
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8889
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8790
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8572
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8652
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4202
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2782
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.