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 11252
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.googlegr oups.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@localhostwrote in message
news:46*********************@news.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.googlegr oups.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...
|
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)...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
| |