I'm looking for a C/C++ library that can get access to the stdin and
stdout of a process. I may invoke a external program in a C/C++
program, but how do write data into the stdin of the external program,
and read data out from the stdout of the external program?
Suggestions are much appreciated. 4 11293
On May 13, 10:02 pm, xman <cshin...@gmail .comwrote:
I'm looking for a C/C++ library that can get access to the stdin and
stdout of a process. I may invoke a external program in a C/C++
program, but how do write data into the stdin of the external program,
and read data out from the stdout of the external program?
Suggestions are much appreciated.
Is the external program already running or does your program start the
external program.
In general there is no C++ standard (and so off topic here) way to do
what you ask but Linux/Unix machines use "popen" and I think Win32 has
a similar _popen function. http://msdn2.microsoft.com/en-us/lib...4b(VS.80).aspx
Any further questions should be directed to a more relevant news
group.
Hi,
Using unix/linux you can do this by closing 0 (input) and 1 (output)
close(0) close(1) in combination with pipe. Then fork another process
(which inherits its parents file descriptors and use the other and of the
pipe created. Sincd file desciptors are assigned beginning with the lowest
available stdin and stdout will be assigned to the pipe.
Regards, Ron AF Greve http://www.InformationSuperHighway.eu
"xman" <cs******@gmail .comwrote in message
news:11******** **************@ y80g2000hsf.goo glegroups.com.. .
I'm looking for a C/C++ library that can get access to the stdin and
stdout of a process. I may invoke a external program in a C/C++
program, but how do write data into the stdin of the external program,
and read data out from the stdout of the external program?
Suggestions are much appreciated.
In additon, a little googling for pipe, close, open gives: http://www.cs.sunysb.edu/~cse533/asgn1/pipes.html
Regards, Ron AF Greve http://www.InformationSuperHighway.eu
"Ron AF Greve" <ron@localhostw rote in message
news:46******** *************@n ews.xs4all.nl.. .
Hi,
Using unix/linux you can do this by closing 0 (input) and 1 (output)
close(0) close(1) in combination with pipe. Then fork another process
(which inherits its parents file descriptors and use the other and of the
pipe created. Sincd file desciptors are assigned beginning with the lowest
available stdin and stdout will be assigned to the pipe.
Regards, Ron AF Greve
http://www.InformationSuperHighway.eu
"xman" <cs******@gmail .comwrote in message
news:11******** **************@ y80g2000hsf.goo glegroups.com.. .
>I'm looking for a C/C++ library that can get access to the stdin and stdout of a process. I may invoke a external program in a C/C++ program, but how do write data into the stdin of the external program, and read data out from the stdout of the external program?
Suggestions are much appreciated.
xman a écrit :
I'm looking for a C/C++ library that can get access to the stdin and
stdout of a process. I may invoke a external program in a C/C++
program, but how do write data into the stdin of the external program,
and read data out from the stdout of the external program?
Suggestions are much appreciated.
I have used pstream with success. It is basically a wrapper around
popen/pclose.
See: http://pstreams.sourceforge.net/
Michael This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: JD |
last post by:
This is another Python problem, I think might be unrelated to
the earlier bug I found, and eventually figured out how to
report it to Sourceforge.
This is related to a question I have about Python hanging up
either from a shell, or by importing a module. This I would not
consider a bug, but more on my inexperience with Python.
If my code causes Python to just hang up, and not allowing me
to break out with control-C or...
|
by: jas |
last post by:
Hi,
I would like to start a new process and be able to read/write from/to
it. I have tried things like...
import subprocess as sp
p = sp.Popen("cmd.exe", stdout=sp.PIPE)
p.stdin.write("hostname\n")
however, it doesn't seem to work. I think the cmd.exe is catching it.
|
by: ccdrbrg |
last post by:
What is the best way to protect stdin within a library?
I am writing a terminal based program that provides plugin
capability using the dlopen() API.
Sequencing program commands (typed) and library input
prompts will not happen if stdin is supplied by pipe
or redirection.
So, I would like to include a statement in the pluggin
|
by: bayer.justin |
last post by:
Hi,
I am trying to communicate with a subprocess via the subprocess
module. Consider the following example:
<subprocess.Popen object at 0x729f0>
Here hey is immediately print to stdout of my interpreter, I did not
type in the "hey". But I want to read from the output into a string,
so I do
|
by: Greg Ercolano |
last post by:
When I use os.popen(cmd,'w'), I find that under windows, the stdout
of the child process disappears, instead of appearing in the DOS window
the script is invoked from. eg:
C:\type foo.py
import os
import sys
file = os.popen("nslookup", 'w')
file.write("google.com\n")
file.close()
| |
by: bhunter |
last post by:
Hi,
I've used subprocess with 2.4 several times to execute a process, wait
for it to finish, and then look at its output. Now I want to spawn
the process separately, later check to see if it's finished, and if it
is look at its output. I may want to send a signal at some point to
kill the process. This seems straightforward, but it doesn't seem to
be working.
Here's my test case:
|
by: rdabane |
last post by:
Hi,
I'm trying to perform following operation from inside the python
script
1. Open a shell ( start a process )
2. Send command1 to the process
3. Get output from the process
4. Send command2 to the process
5. Get output from the process
.......
|
by: Gabriel Genellina |
last post by:
En Thu, 25 Sep 2008 09:49:31 -0300, Almar Klein <almar.klein@gmail.com>
escribió:
Use subprocess.PIPE
Usually the tricky part is to figure out exactly whether there is more
input or not. With Python it's easy, use the ps1 prompt.
--- begin ---
import sys
|
by: Samuel A. Falvo II |
last post by:
I have a shell script script.sh that launches a Java process in the
background using the &-operator, like so:
#!/bin/bash
java ... arguments here ... &
In my Python code, I want to invoke this shell script using the
Subprocess module. Here is my code:
def resultFromRunning_(command):
|
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,...
|
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...
| |
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |