473,480 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Command pipes in C++

Hi, sorry if you found I have multi posted in different groups. It didn't
appear in that group.

I am trying to write an automated testing program with CxxTest, which in
turn needs to talk to gdb through the command line.

The program should give some command to gdb, the debugger program. And then
get the results out of it. Just like when we debug with gdb, we type in
those commands, and see the results. But this has to be done in an automated
way.

It is very similar to the pipes in scripting language, but the test has to
be done with C++.

Please help. Thank you very much.

Peng
Jul 22 '05 #1
5 3197
Peng Yuan Fan wrote:
Hi, sorry if you found I have multi posted in different groups. It
didn't appear in that group.

I am trying to write an automated testing program with CxxTest, which
in turn needs to talk to gdb through the command line.

The program should give some command to gdb, the debugger program. And
then get the results out of it. Just like when we debug with gdb, we
type in those commands, and see the results. But this has to be done
in an automated way.

It is very similar to the pipes in scripting language, but the test
has to be done with C++.

Please help. Thank you very much.

Peng


This is a platform sepcific question. Standard C++ has no way to open
such a pipe between two programs.

Under POSIX systems, you might want to have a look at the manual page of
the pipe() system call.

Jul 22 '05 #2
Peng Yuan Fan wrote:
Hi, sorry if you found I have multi posted in different groups. It didn't
appear in that group.

I am trying to write an automated testing program with CxxTest, which in
turn needs to talk to gdb through the command line.

The program should give some command to gdb, the debugger program. And then
get the results out of it. Just like when we debug with gdb, we type in
those commands, and see the results. But this has to be done in an automated
way.

It is very similar to the pipes in scripting language, but the test has to
be done with C++.


Standard C++ has no support for pipes; you need platform specific
methods to accomplish what you want. Maybe your platform supports the
popen() function.

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl
Jul 22 '05 #3
"Peng Yuan Fan" <py**********@no-spam.cam.ac.uk> wrote in message news:<cb**********@pegasus.csx.cam.ac.uk>...
Hi, sorry if you found I have multi posted in different groups. It didn't
appear in that group.

I am trying to write an automated testing program with CxxTest, which in
turn needs to talk to gdb through the command line.
Use Expect.
It is very similar to the pipes in scripting language, but the test has to
be done with C++.


Not a compelling reason.

/david
Jul 22 '05 #4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peng Yuan Fan wrote:
Hi, sorry if you found I have multi posted in different groups. It didn't
appear in that group.

I am trying to write an automated testing program with CxxTest, which in
turn needs to talk to gdb through the command line.

[snip]
Since you are already using the gcc tool chain, arguments to the effect
that pipes are platform specific are not necessarily valid as even on MS
products, as long as you install the cigwin environment, you have pipes.
That being said, your only issue is to deal with the pipes man pages. To
start work with pipes, try looking up the following man pages: pipe
(gives you 2 file descriptors), dup2 (which allows you to redirect input
& output), and fork.

Generally, you create your in/out pair with something like pipe prior to
forking, then in the child, redirect your IO to the appropriate fd. Ok,
so all that sounds great, but as one of the previous respondents said,
if you don't need to use this in an existing C++ program, expect isn't a
bad choice of an app to use which already has this all tied up.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFA5Du3oo/Prlj9GScRAmGfAJ4pSdrwvtdoupLNpTpfqOzeMMlsIgCfQFJE
tI+9jUnYfKcx0yjN7mW4oyc=
=6z0v
-----END PGP SIGNATURE-----
Jul 22 '05 #5
On Wed, 30 Jun 2004 11:51:21 +0100, Peng Yuan Fan wrote:
Hi, sorry if you found I have multi posted in different groups. It didn't
appear in that group.

I am trying to write an automated testing program with CxxTest, which in
turn needs to talk to gdb through the command line.

The program should give some command to gdb, the debugger program. And then
get the results out of it. Just like when we debug with gdb, we type in
those commands, and see the results. But this has to be done in an automated
way.

It is very similar to the pipes in scripting language, but the test has to
be done with C++.
Take a look at http://libexecstream.sourceforge.net/
From the project's description:
"Libexecstream is a C++ library that allows you to run a
child process and have its input, output and error avaliable
as standard C++ streams."

HTH,
Peter.


Please help. Thank you very much.

Peng


Jul 22 '05 #6

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

Similar topics

0
2260
by: Christian Hammers | last post by:
Hello I would like to call a unix shellscript from within a PHP script and - write data to its STDIN - read data from its STDOUT *and* STDERR - get its exit code afterwards proc_open seems...
0
1898
by: kpohl | last post by:
Hi! It would be great if anyone could help me with this problem: I want to check the syntax of my php code. Therefore I use the command line function PHP -l, the structure is similar to the...
4
9892
by: Christian Long | last post by:
Hi I'm trying to pipe data into a python program on Windows 2000, on the command line. Like this: dir | myProgram.py Here's what I tried:
8
3670
by: Hugh Macdonald | last post by:
I'm calling a command from within a python script and I need to be able to both catch the output (stdout and stderr) from it and also have the PID (so that I can kill it) I can do one or other...
6
2499
by: calmar | last post by:
Hi all, I would like to use python for a replacement for some binutils. I would like to be able to pipe things into python. Actually I would not like writing a 'script' to handle the input, but...
5
18099
by: glenn.owens | last post by:
In the process of doing some routine monitoring/clean-up we've discovered that several (many?) users are apparently set to access our SQL Server 2000 database instances via the Named Pipes...
9
2534
by: Hans J?rg Brinksmeyer | last post by:
Hi, does anyone have an idea for this problem: I use anonymous pipes to steer a console program under Win2000 with a second 'steering aplication'. The stdin and output are redirected to...
2
3353
by: twigster | last post by:
Hi, I need to display in real time the output of a command line tool in a GUI written so far with Tkinter and Pmw. I've got a command line tool that I want to integrate to a GUI. The parameters...
7
7602
by: andrewb | last post by:
Hi all, Having some trouble using named pipes and Visual Basic .NET and would appreciate and help you could offer. Essentially I am trying to develop a simple client/server application that...
0
7055
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
6920
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...
0
7059
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,...
0
7103
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...
1
4799
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...
0
4499
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...
0
3011
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...
0
1311
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 ...
0
203
bsmnconsultancy
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...

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.