c++ data pipe

D

David

im trying to figure out how to pipe data to an application with c++
Here is how I would do it in perl
open(OSA, "| /usr/bin/osascript") || die "Can't pipe to osascript";
print OSA "some text to pipe\n";
close(OSA);

can someone show me the equivilent in c++?
thanks
 
G

gMorphus

David said:
im trying to figure out how to pipe data to an application with c++
Here is how I would do it in perl
open(OSA, "| /usr/bin/osascript") || die "Can't pipe to osascript";
print OSA "some text to pipe\n";
close(OSA);

can someone show me the equivilent in c++?
thanks

You can do one of the following:
1. Redirect the standard output to some file or other file interface
using
stream = freopen( "freopen.out", "w", stdout );
(you can replace stdout with stderr to redirect standard error)

2. Use Interprocess Communication Mechanism. If you use unix I can't
help you there. You should search for it.

3. Btw, you can simply use pipe. Use the command to redirect the
standard output...
 
J

Jerry Coffin

im trying to figure out how to pipe data to an application with c++
Here is how I would do it in perl
open(OSA, "| /usr/bin/osascript") || die "Can't pipe to osascript";
print OSA "some text to pipe\n";
close(OSA);

can someone show me the equivilent in c++?

Not really -- c++, per se, doesn't provide an equivalent. Assuming
you're using something at least vaguely similar to UNIX, if you ask
about popen() in a newsgroup devoted to development for that OS, they'll
be able to help you out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top