473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

how to call an external program?

Is there a standard way in C++ to call an external program or is this
platform dependent?

If it is platform dependent, can somebody drop a line what to use or
where to look for info for GNU C++ on RedHat? I am doing some numerical
calculations and need to invoke an external plotting program (gnuplot)
and return to the numerics.

Sorry if I posted twice.

Thanks,
Sanyi

Jul 22 '05 #1
10 8211
On Sat, 13 Dec 2003 22:48:28 -0500, Sanyi Benczik wrote:
Is there a standard way in C++ to call an external program or is this
platform dependent?

If it is platform dependent, can somebody drop a line what to use or
where to look for info for GNU C++ on RedHat? I am doing some numerical
calculations and need to invoke an external plotting program (gnuplot)
and return to the numerics.


I don't know how platform independent this is, but <stdio.h> contains:
FILE *popen(const char *command, const char *type);
This allows you to open a program and either read stdin ("r") or write stdout
("w") in the same manner as fopen.

There is probably a better solution, but this is the first thing that came
to mind.

-Brian
Jul 22 '05 #2
man system 3

Sanyi Benczik wrote:
Is there a standard way in C++ to call an external program or is this
platform dependent?

If it is platform dependent, can somebody drop a line what to use or
where to look for info for GNU C++ on RedHat? I am doing some numerical
calculations and need to invoke an external plotting program (gnuplot)
and return to the numerics.

Sorry if I posted twice.

Thanks,
Sanyi


Jul 22 '05 #3
Sanyi Benczik <sb******@vt.edu> wrote in message news:<br**********@solaris.cc.vt.edu>...
Is there a standard way in C++ to call an external program or is this
platform dependent?

If it is platform dependent, can somebody drop a line what to use or
where to look for info for GNU C++ on RedHat? I am doing some numerical
calculations and need to invoke an external plotting program (gnuplot)
and return to the numerics.

Sorry if I posted twice.

Thanks,
Sanyi


I am not sure, but maybe System(char *) might seem helpful... Then you
can pipe the output to your program or something.
Jul 22 '05 #4
cm****@yahoo.com (Chris Mantoulidis) wrote in message news:<a8**************************@posting.google. com>...
Sanyi Benczik <sb******@vt.edu> wrote in message news:<br**********@solaris.cc.vt.edu>...
Is there a standard way in C++ to call an external program or is this
platform dependent?
#include <stdlib.h>

int system(const char* progCmdLin); // standard, fairly limited in
capability

If it is platform dependent, can somebody drop a line what to use or
where to look for info for GNU C++ on RedHat? I am doing some numerical
calculations and need to invoke an external plotting program (gnuplot)
and return to the numerics.
Depending how you want to design your program, you have a few options.

Popen is definitely one.

It might make sense to let the gnuplot program come up separately,
display your graph and stay there while the processing logic
continues.

Then you can spawn a process or a thread asynchronously to do that.
Lookup how to use system APIs. Look for the execle, execlp, execve,
execvp APIs plus the fork API.

Sorry if I posted twice.

Thanks,
Sanyi


I am not sure, but maybe System(char *) might seem helpful... Then you
can pipe the output to your program or something.

Jul 22 '05 #5
Sanyi Benczik wrote:
Is there a standard way in C++ to call an external program or is this
platform dependent?

If it is platform dependent, can somebody drop a line what to use or
where to look for info for GNU C++ on RedHat? I am doing some numerical
calculations and need to invoke an external plotting program (gnuplot)
and return to the numerics.


I believe that gnuplot has C and C++ interfaces. So you don't need to call
any extrenal program, just include some header files initialize it and link
with right libraries.

(At RH you probbably need to install gnuplot-devel RPM package)

See www.gnuplot.info

And then write me your experiences with this, please :-).

--
mP

http://pivoluska.matfyz.cz/
Jul 22 '05 #6
Brian Kerrick Nickel wrote:
On Sat, 13 Dec 2003 22:48:28 -0500, Sanyi Benczik wrote:

Is there a standard way in C++ to call an external program or is this
platform dependent?

If it is platform dependent, can somebody drop a line what to use or
where to look for info for GNU C++ on RedHat? I am doing some numerical
calculations and need to invoke an external plotting program (gnuplot)
and return to the numerics.

I don't know how platform independent this is, but <stdio.h> contains:
FILE *popen(const char *command, const char *type);
This allows you to open a program and either read stdin ("r") or write stdout
("w") in the same manner as fopen.

There is probably a better solution, but this is the first thing that came
to mind.

-Brian

FYI, "popen" is not a standard C++ function. I doesn't exist in at
least two of my compilers.
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 22 '05 #7
Jeff Schwab wrote:
man system 3

Sanyi Benczik wrote:
Is there a standard way in C++ to call an external program or is this
platform dependent?

If it is platform dependent, can somebody drop a line what to use or
where to look for info for GNU C++ on RedHat? I am doing some
numerical calculations and need to invoke an external plotting program
(gnuplot) and return to the numerics.

Sorry if I posted twice.

Thanks,
Sanyi

Please do not reply with platform specific information
and also don't top-post.

Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.

C:\>man system 3
No manual entry for system
What manual page do you want from section 3?

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 22 '05 #8
Chris Mantoulidis wrote:
Sanyi Benczik <sb******@vt.edu> wrote in message news:<br**********@solaris.cc.vt.edu>...
Is there a standard way in C++ to call an external program or is this
platform dependent?

If it is platform dependent, can somebody drop a line what to use or
where to look for info for GNU C++ on RedHat? I am doing some numerical
calculations and need to invoke an external plotting program (gnuplot)
and return to the numerics.

Sorry if I posted twice.

Thanks,
Sanyi

I am not sure, but maybe System(char *) might seem helpful... Then you
can pipe the output to your program or something.


BTW, the function is "system". The C++ language is case-sensitive,
"system" and "System" are different identifiers.
--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

Jul 22 '05 #9


Thomas Matthews wrote:
Jeff Schwab wrote:
man system 3
Please do not reply with platform specific information


Sorry; my mistake!

<ot> and also don't top-post.


Top-posting has gotten a bad rap. I'm bringing it back into fashion! :)
Seriously, I think it's often appropriate, but I guess that's sort of
a dead horse... <grumble/><grumble/>

</ot>

Jul 22 '05 #10
> BTW, the function is "system". The C++ language is case-sensitive,
"system" and "System" are different identifiers.


I know C++ is case-sensitive (d'oh)... I just haven't used
sytem(char*) for a long time. I don't really need it... I have other
alternatives ;)

cmad
Jul 22 '05 #11

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

Similar topics

0
by: Dave Sisk | last post by:
I've created a system or external trigger on an AS/400 file a.k.a DB2 table. (Note this is an external trigger defined with the ADDPFTRG CL command, not a SQL trigger defined with the CREATE...
8
by: Greg Fierro | last post by:
I would appreciate any help from anyone with the following: I have an external program (window32 based) that I am executing with the VBA SHELL command. This program produces a text file which I...
1
by: Laszlo | last post by:
Hi all, As a novice I installed PostgreSQL 7.2.1 on Win32 and works, Borland C++Builder Enterprise Suite 5.0 (build 12.34) what works too. I decided to combine these two programs and develop a...
3
by: Niko Schwarz | last post by:
Hello, I'd like to run check from within my c program a gnupg signature. The easiest way should be to simply call gnupg, right? But how do i get the output of that program into a string? best...
4
by: My SQL | last post by:
Hi Can I trigger an external program to run when a new record is added to the mysql table? The external program is in C and instead of scanning the table continuously for new insertions, it...
5
by: snicks | last post by:
I'm trying to exec a program external to my ASP.NET app using the following code. The external app is a VB.NET application. Dim sPPTOut As String sPPTOut = MDEPDirStr + sID + ".ppt" Dim p As...
2
by: Serman D. | last post by:
Hi all, I'm trying to complete the samples from the excellent 2003 developerWorks article "Bringing the Power of Regular Expression Matching to SQL" by Knut Stolze: http://tinyurl.com/3bhrnn...
2
by: dolphin | last post by:
What is the different between c++ call convention and c call convention?Can some give some examples?
2
by: =?Utf-8?B?YmFzaA==?= | last post by:
Hello, I am compiling a CPP code using Visual studion .net 2003. I get the following error, despite having windldap.h and wldap32.dll in my include and lib paths. Here is the error. uuid.lib...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.