472,988 Members | 2,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,988 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 8182
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.