|
From: Dave D. <dde...@es...> - 2006-05-23 09:24:31
|
Hans-Bernhard Br=F6ker <br...@ph...> writes:
> Markus Feldmann wrote:
>
> [...]
>> The filename of my batch file may be for example "aufg11.batch".
>> In this batch file i wanna use a file which has got values.
>> The name of this file is "aufg11.dat".
>> I don't want to,
>> plot "aufg11.dat" ...
>> but i want to,
>> plot "$filename"
>> or something like this.
>
> Sorry, no can do. Not with a filename that was used to run gnuplot
> on, like that, anyway. You can refer to environment variables,
> though, if your platform is sufficiently Unix-like ...
>
I think he said it was debian.
I was pondering over somehow figuring it out from /proc/self but I've
not really come with anything. Unfortunately, if you invoke a subshell
to do any parsing, it will have a different /proc/self - I wonder if
the linux people have considered adding a /proc/pid/ppid soft-link to
the /proc entry of the parent ?
Best I came up with was
gnuplot < batchfile
then a subshell would inherit stdin, and could get the filename from
its own /proc/self/fd/0
> plot "`echo $FILE`.dat"
>
> Or even move the entire scripting job off gnuplot's shoulders onto
> that of the shell, by using a "HERE" script:
>
> gnuplot -persist <<\EOF
> plot "$1.dat"
> EOF
>
>
> or the somewhat simpler
>
> echo plot "$1.dat" | gnuplot -persist
>
Or perhaps a wrapper script which derives the filename from $1, stuffs
it into an env. variable (or opens a fixed fd for it) and execs the
real gnuplot ?
$ gnuplot-wrapper batchfile
where gnuplot-wrapper is a shell-script with
export DATAFILE=3D${1/batch/dat}
exec gnuplot $*
and the script can access $DATAFILE
or perhaps
exec gnuplot $* 20< ${1/batch/dat}
and then the script can access the datafile as /proc/self/fd/20
dd
--=20
Dave Denholm <dde...@es...> http://www.esmertec=
.com
|