Dear all,
I am making a system call to the well known Gnuplot with
system("gnuplot ");
gnuplot opens if I only supply this command but I would like to pipe
that command line in my C++ program. For example I want to run a very
simple command like "plot sin(x)". So after running another program,
what is the way to pipe that with some commands from inside the c++
program.
Or should I ask this in Gnuplot forums?
Thx for the replies in advance. 18 7527
utab wrote: Dear all,
I am making a system call to the well known Gnuplot with
system("gnuplot ");
gnuplot opens if I only supply this command but I would like to pipe that command line in my C++ program. For example I want to run a very simple command like "plot sin(x)". So after running another program, what is the way to pipe that with some commands from inside the c++ program.
system() is supposed to supply the given command line to the system's shell
if possible. So the command that you want to execute should be given to
system() just like you would type it in the shell.
Or should I ask this in Gnuplot forums?
This is not gnuplot specific, so no.
like this
system("gnuplot plot sin(x)");
compiles
but gives errors:
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `gnuplot plot sin(x)'
utab wrote: like this
system("gnuplot plot sin(x)");
compiles
but gives errors:
sh: -c: line 0: syntax error near unexpected token `(' sh: -c: line 0: `gnuplot plot sin(x)'
Your shell interprets the '(' in a way that you don't want. What happens if
you enter
gnuplot plot sin(x)
directly into your shell? I'd guess the same. Find out what the correct
command line has to look like.
bash: syntax error near unexpected token `('
Do I have check gnuplot or my shell
Thx
utab wrote: bash: syntax error near unexpected token `('
Do I have check gnuplot or my shell
What did you do? Call system("source. cpp")?
That error looks like bash saw .cpp source.
--
Phlip http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
utab wrote: bash: syntax error near unexpected token `('
Do I have check gnuplot or my shell
Your shell.
Phlip wrote: utab wrote:
bash: syntax error near unexpected token `('
Do I have check gnuplot or my shell
What did you do? Call system("source. cpp")?
That error looks like bash saw .cpp source.
-- Phlip http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
I did
like this
system("gnuplot plot sin(x)");
compiles
but gives errors:
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `gnuplot plot sin(x)'
utab wrote: system("gnuplot plot sin(x)");
compiles
but gives errors:
sh: -c: line 0: syntax error near unexpected token `(' sh: -c: line 0: `gnuplot plot sin(x)'
This is now a question for a bash forum, so if the following tips are wrong,
please complain there and not here.
Bash probably interprets the (), so you can escape them:
system("gnuplot plot sin\\(x\\)");
system("gnuplot \"plot sin(x)\"");
But that won't work. Bash will like them but gnuplot won't. (And the sin(x)
most certainly will not convert to a call to your program's sin()
function.) Write a file with your data and commands in it, and pass the
filename on Gnuplot's command line. Get Gnuplot working on a command line,
first, before coming back to C++. And consider driving Gnuplot with a
softer language, such as Ruby. There are a couple of Gnuplot wrapper
classes available there.
--
Phlip http://www.greencheese.org/ZeekLand <-- NOT a blog!!!
utab wrote: Dear all,
I am making a system call to the well known Gnuplot with
system("gnuplot ");
gnuplot opens if I only supply this command but I would like to pipe that command line in my C++ program. For example I want to run a very simple command like "plot sin(x)". So after running another program, what is the way to pipe that with some commands from inside the c++ program.
What you want to do is very specific to OS. If you want to interact
with an external program you have to use the posix function exec (or
one of its friends) and set up your stdin/out correctly. It's easy but
somewhat complex and is off topic. Ask in a linux/unix programmer
ground and/or google for the unix programming faq.
system() will run and block until the program is done (I believe, I
don't use it because it is usually too limited) and get the output but
won't let you interact with it...you can't "pipe" commands to your
external program with system().
There are also utility classes in frameworks such as Qt. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Albert Ahtenberg |
last post by:
Hello,
I had some bad experience with code organization and script
functionality in writing my php based applications. And as the applications
get bigger in scale it gets even worse. Therefore, I am trying to build a
general schema for data flow in a php/mysql application.
What I has in mind is to design a three major units. To handle the
input, processing and data access. Plus another unit to generate the output.
|
by: Bruce W...1 |
last post by:
A scripting newbie question... I'm trying to understand some code I found.
This script conducts a poll and writes the results to a text file. The
following statement is part of the source file. The exact code is not important
to my question so don't wrack your brain on this.
if (isset($votingstep)) {
function ShowTheStuff($item, $itemvoted, $graph_width, $graph_height) {
$hector=count($itemvoted);$totalvotes=0;$in=0;$stepstr='';...
|
by: Lil |
last post by:
Hi Everyone! I've been trying to figure out this weird bug in my
program. I have a python program that calls a C function that reads in
a binary file into a buffer. In the C program, buffer is allocated by
calling malloc. The C program runs perfectly fine but when I use python
to call the C function, it core dumps at malloc.
I've tried multiple binary files with different sizes and the result
is:
if file size is < 20 bytes , works fine...
|
by: jacob navia |
last post by:
Suppose that you want to know where your program has
passed, i.e. the exact flow of the program.
A brute force solution is to make an array of n lines, n being
the number of lines in the function. At each line then, you increment
a variable like this:
// NRLINES is the number of lines in the program module
int lines;
int fn(int a)
|
by: Brett |
last post by:
I'd like to have all of my documentation in one place. I use the following
for documenting code:
- attributes for certain types of documentation
- use of the C# generated inline XML documentation
- simple comments
I also use Visual Paradigm for UML (class relationships), which integrates
with VS.NET. I need something for general documentation of program flow.
Any suggestions on what to use for this?
| |
by: seattleboatguy |
last post by:
I am trying to send a message from a visual c++ user-thread to the main
window, so the main window can update text on the window to reflect
what the user-thread is doing. I have tried 2 different approaches, and
both fail. I don't know what to try next.
+++++++++++++++++++++++++++++++++++++++++++++++++++++
APPROACH #1: (this approach makes the most sence to me)
Configure the first parameter of the thread's PostMessage() to talk to
the...
|
by: lovecreatesbea... |
last post by:
K&R 2, sec 2.4 says: If the variable in question is not automatic, the
initialization is done once only, conceptually before the program
starts executing, ... .
"Non-automatic variables are initialized before the program starts
executing." -- What does this mean? What is the name of the stage in
which the mentioned initialization is performed? Compile-time or
run-time?
In the following snippet, variables b and c are defined at line 7...
|
by: Crooter |
last post by:
Hello colleagues,
Could anybody tell me if there are existing open-source solutions to
extract the program tree using a program source code? I'm aware that
GCC has program flow information and tree respectively for
optimization, but I'm looking for something less complicated.
An ideal case would be a small program based on a parser with YACC
compatible grammar which extracts the program flow tree.
Best regards,
|
by: Sagari |
last post by:
Greetings,
Can someone suggest an efficient way of calling method whose name is
passed in a variable?
Given something like:
class X:
#...
def a(self):
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |