I am trying to plot something in gnuplot 4.2 using co-ordinates a Python
2.5 program computes. Here's what I'm doing:
pyfrom subprocess import *
pyplot = Popen("c:/progs/gp/bin/wgnuplot.exe", stdin=PIPE)
pyplot.stdin.wr ite("plot x*x")
The first command dutifully opens gnuplot, but the second doesn't do
anything. Could someone favour me with an explanation as to the whyness?
--
Peter 3 3972
On 2007-04-25, Peter Beattie <Pe***********@ web.dewrote:
I am trying to plot something in gnuplot 4.2 using co-ordinates a Python
2.5 program computes. Here's what I'm doing:
pyfrom subprocess import *
pyplot = Popen("c:/progs/gp/bin/wgnuplot.exe", stdin=PIPE)
pyplot.stdin.wr ite("plot x*x")
The first command dutifully opens gnuplot, but the second doesn't do
anything. Could someone favour me with an explanation as to the whyness?
I think it may just be that you need a newline after "plot x*x", i.e.
plot.stdin.writ e("plot x*x\n")
or
print >>plot.stin, "plot x*x"
But some interactive programs need to be controlled with expect rather
than just writing to their stdin. I'm unclear of the details, perhaps
it's just ones that use curses in some form.
I usually write the gnuplot commands to a file, and then use
os.system("gnup lot plot.gpi") to run gnuplot in batch mode (or gnuplot
-persist if you want the window). You can also use Popen instead of
os.system.
Peter Beattie wrote:
I am trying to plot something in gnuplot 4.2 using co-ordinates a Python
2.5 program computes. Here's what I'm doing:
pyfrom subprocess import *
pyplot = Popen("c:/progs/gp/bin/wgnuplot.exe", stdin=PIPE)
pyplot.stdin.wr ite("plot x*x")
The first command dutifully opens gnuplot, but the second doesn't do
anything. Could someone favour me with an explanation as to the whyness?
Why re-invent the wheel? Not trying to be pedantic, but usually the
google search
"python %s" % thing_im_workin g_on
will yield lucrative results that far exceed anything you can create in
a reasonable amount of time. For example, "python gnuplot" first hit is: http://gnuplot-py.sourceforge.net/
And speaking from experience, it works beautifully.
James
On 2007-04-25, Peter Beattie <Pe***********@ web.dewrote:
I am trying to plot something in gnuplot 4.2 using co-ordinates a Python
2.5 program computes. Here's what I'm doing:
pyfrom subprocess import *
pyplot = Popen("c:/progs/gp/bin/wgnuplot.exe", stdin=PIPE)
pyplot.stdin.wr ite("plot x*x")
The first command dutifully opens gnuplot, but the second doesn't do
anything. Could someone favour me with an explanation as to the whyness?
wgnuplot.exe doesn't read commands from stdin. However,
pgnuplot.exe does (that's why it exists).
It's probably easier to just use the gnuplot-py module: http://gnuplot-py.sourceforge.net/
The "released" 1.7 version still uses Numeric. I believe
that it's been converted over to numpy, so if you prefer numpy
over Numeric, you can grab an SVN snapshot.
--
Grant Edwards grante Yow! My face is new, my
at license is expired, and I'm
visi.com under a doctor's care!!!! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: madpython |
last post by:
playing with subprocess.Popen on Windows I stumbled into the following
problem:
Python 2.4.3 (#69, Mar 29 2006, 17:35:34)
IDLE 1.1.3
>>> import subprocess
>>> p1=subprocess.Popen("c:\\asd.bat") #works OK
>>> p2=subprocess.Popen("c:\\asd.bat",stdout=subprocess.PIPE)
|
by: Clodoaldo Pinto Neto |
last post by:
Output from the shell:
$ set | grep IFS
IFS=$' \t\n'
Output from subprocess.Popen():
"IFS=' \t\n"
Both outputs for comparison:
|
by: bayer.justin |
last post by:
Hi,
I am trying to communicate with a subprocess via the subprocess
module. Consider the following example:
<subprocess.Popen object at 0x729f0>
Here hey is immediately print to stdout of my interpreter, I did not
type in the "hey". But I want to read from the output into a string,
so I do
|
by: Eric_Dexter |
last post by:
I am trying to modify a programming example and I am coming up with
two problems... first is that I can't seem to pass along the
arguments to the external command (I have been able to do that with
the old module and cmd is the command I wish to try) all the output
seems to be returned as one line (at least when I run the program in
spe).
import subprocess
from os import system
cmd = """gawk -f altertime.awk -v time_offset=4 -v
|
by: Mrown |
last post by:
Hi,
I'm currently writing a python program that relies on a CLI
program. What I'm currently doing is using subprocess.Popen on Python
2.5.1. Here's the line that I'm currently running:
child = subprocess.Popen(, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
The problem is that although the above works, a CMD shell is spawned
and becomes visible for each time I run the above. I thought that by
| |
by: skunkwerk |
last post by:
Hi,
i'm trying to call subprocess.popen on the 'rename' function in
linux. When I run the command from the shell, like so:
rename -vn 's/\.htm$/\.html/' *.htm
it works fine... however when I try to do it in python like so:
p = subprocess.Popen(,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
print p.communicate()
|
by: Jeremy Banks |
last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the
Popen class in the subprocess module. Popen sounds like the a suitable
name for a function that created a subprocess, but the object itself is
a subprocess, not a "popen". It seems that it would be more accurate to
just name the class Subprocess, can anyone explain why this is not the
case?
Thank you.
|
by: Mark Shewfelt |
last post by:
Hello,
I am attempting to use Popen() in a Windows service. I have a small
Win32 .exe that I normally run through the os.popen2() function. I've
written a class to work with the input and output parameters that are
passed and captured from this exe. When I use the class outside of a
service using either subprocess.Popen or os.popen2 work just fine.
When I use this class inside a Windows service it doesn't work. It
doesn't crash the...
|
by: thedsadude |
last post by:
Hello,
I'm launching a script as follows:
<code>
p = subprocess.Popen()
p.wait()
</code>
If p.py writes to sys.stdout, then it is shown on the console.
|
by: siavashr |
last post by:
Hi,
I am new to python, and I am trying to do the following from my python code:
echo 1 > /sys/devices/omapdss/display0/enabled
I have tried to do this with the following functions:
os.popen('echo 0 > "/sys/devices/omapdss/display0/enabled"')
|
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: 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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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: 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: 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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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?
| |