Wrox Programmer Forums
|
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 24th, 2004, 10:36 AM
Registered User
 
Join Date: Aug 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default System Call

  Hi everyone!

  I'm a beginner programmer in C++, and a I'm a new one in this forum. So, pleasure!

  As long I'm doing my first steps, I need to develop a program that will invoke gnuplot, a graphic software. I know I need to do a system call to invoke another program, but I don't know very much about the syntax ... can anyone help me?

  Thanks in advance!

Reply With Quote
  #2 (permalink)  
Old August 24th, 2004, 11:25 AM
Authorized User
 
Join Date: Feb 2004
Posts: 76
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The function system() executes a program.

For example in Windows if the executable is in C:\bin
Code:
  system("C:\\bin\\wgnupl32.exe");
In Linux/Unix if the executable is in /bin

Code:
  system("/bin/gnuplot");
The string in the argument to system should be the same that you would use from a command line. You can include arguments to the application within the string.

Dave
Reply With Quote
  #3 (permalink)  
Old January 20th, 2005, 05:11 PM
Authorized User
 
Join Date: Aug 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Spivonious
Default

Hey, I know I'm calling up a pretty old thread, but I have a question.

Can the system() call be used to provide input for the program called with system()?

Just in case you're wondering, I'm trying to write a program that can be used to test another program. arguments are the program to be tested, a file containing test inputs, and a file to put the output.
Reply With Quote
  #4 (permalink)  
Old January 24th, 2005, 02:01 PM
Registered User
 
Join Date: Jan 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Keith E. Cooper
Default

As was stated earlier, what ever your command line can accept can go into the string passed to the system() call. So if the program you wish to invoke is in /home/me/bin, is named test1, takes an input file name for an argument, and you wish stdout to be written to a file, the string might look like this:

"/home/me/bin/test1 < myinputfile > myoutputfile"

Note that this isn't very flexible if the string were hard-coded: You must recompile if you change any options.

Reply With Quote
  #5 (permalink)  
Old March 30th, 2006, 06:25 AM
Registered User
 
Join Date: Mar 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi dear, Would anyone like to show me any simple C++ code that executes a gnuplot program?If it is not possible, do you know any information helpful about that?

Thanks so much!

Reply With Quote





Similar Threads
Thread Thread Starter Forum Replies Last Post
Insert System date and System Time -Form _TextBox cnkumar74 VB How-To 14 February 14th, 2007 10:52 AM
Accessing System Resources of a Remote System harsh_hot J2EE 0 February 9th, 2006 01:13 AM
Casting System::Object __gc * to System.Double[] nepsat Visual C++ 3 November 19th, 2005 12:51 PM
mount system call ur_cherub Linux 1 June 25th, 2004 07:24 AM
call by system Dennis Pro JSP 0 December 2nd, 2003 11:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.