|
From: Leo B. <l_b...@us...> - 2014-03-26 20:55:48
|
> I am wondering if it is possible to make gnuplot to output
> "Content-Type: image/svg+xml" to use gnuplot scripts directly with cgi.
>
> E.g. for this
>
> #!/usr/bin/gnuplot
> set terminal svg
> plot sin(x)
>
> I currently have to use a wrapper:
>
> #!/bin/bash
> echo "Content-Type: image/svg+xml"
> echo
> $PWD/myplot.gnu
If you set up a naming convention, this can be made to work. Call your
script graphics.sh and for each gnuplot script, foo.gnu, have a
symlink foo.sh to graphics.sh. Change the last line to
gnuplot ${0/%gnu/sh}
Now only one script is needed.
>
> But having a wrapper script for each gnuplot script is not ideal.
> I tried to add this to the gnuplot script:
>
> print "Content-Type: image/svg+xml"
> print ""
>
> but then this goes to STDERR instead of STDOUT so next I also added
>
> set output "STDOUT"
>
> but then only the header is displayed and the svg data is missing.
set output "STDOUT"
redirects the output to a file named STDOUT.
The following works for me. All output is sent to stdout.
# send printed output to stdout
set print "-"
print "Content-Type: image/svg+xml"
print ""
set terminal svg
plot [0:2*pi] sin(x)
Leo
|