Basic Python Questions - Oct. 31, 2013
JimSGibson at gmail.com
Sun Nov 3 19:18:09 CET 2013
In article <OKCdnXfaQqxze-jPnZ2dnUVZ_jGdnZ2d at earthlink.com>, E.D.G.
<edgrsprj at ix.netcom.com> wrote:
> My main, complex programs won't be run at Web sites. They will
> instead continue to be available as downloadable exe programs. The CGI (or
> whatever) programming work would involve relatively simple programs. But
> they would need to be able to generate charts that would be displayed on Web
> pages. That sounds like it is probably fairly easy to do using Python. A
> Perl - Gnuplot combination is also supposed to be able to do that. But so
> far I have not seen any good explanations for how to actually get Gnuplot to
> run as a callable CGI program. So other programs such as Python are being
One way to generate plot within a CGI program is this:
1. Write a file with gnuplot commands (e.g., 'gnuplot.cmd') that set
the output device to a graphics file of some format (e.g., PNG),
generate a plot, and quit gnuplot.
2. Run gnuplot and point it to the file of commands (e.g., 'gnuplot
gunplot.cmd') . How this is done depends upon the CGI program language
3. Generate HTML that uses the generated graphics file as an embedded
image (using the <img> tag).
I have done this in the past, but not recently. This should work for
Python (os.system("gnuplot gnuplot.cmd") or Perl (system("gnuplot
gnuplot.cmd") with suitable commands to execute external programs.
More information about the Python-list