Is it possible to pass arguments into a GNUPLOT script?
Some folks suggest that shell environment variables may be used for
this purpose. Does anyone have an example, or two?
Thank you!
> Is it possible to pass arguments into a GNUPLOT script?
[A side remark: the name of the program is "gnuplot". Not GNUplot, nor
GnuPlot, nor GNUPLOT.]
> Some folks suggest that shell environment variables may be used for
> this purpose. Does anyone have an example, or two?
The time-honoured method is by back-tick substitution:
set variable=`echo $VARIABLE`
This runs the echo command in a sub-shell, and puts the result into a
gnuplot variable.
Just a remark. It should be
set variable `echo $VARIABLE`
And if the parameter is text, it should be
set variable "`echo $VARIABLE` "
On Oct 26, 5:06 pm, Hans-Bernhard Bröker <HBBroe...@t-online.de>
wrote:
It is probably easier to use the "-e" command line option of the
more recent versions of gnuplot to set a variable:
$ gnuplot -e 'var=value' script.gp
Juergen
> Is it possible to pass arguments into a GNUPLOT script?
Sometimes, I use gnuplot in a here-document:
#!/bin/sh
gnuplot <<EOF
[...] "$VARIABLE" [...]
EOF
> Thank you! It works!!
>
> Just a remark. It should be
>
> set variable `echo $VARIABLE`
>
> And if the parameter is text, it should be
>
> set variable "`echo $VARIABLE` "
>
Or, if you are doing this inside gnuplot itself:
variable = "`echo $VARIABLE`"
In other words, you don't need to load the value of the environmental
variable as part of the calling script, you can let gnuplot itself
retrieve the current value.