|
From: Markus F. <fel...@gm...> - 2006-05-18 20:00:36
|
Hey, I wanna to execute my batch file, gnuplot filename.batch In my batch file i wanna use the filename. How to do this? I am using Gnuplot under Debian. For example in bash scripts its the same as you would use the $0 . mfg Markus |
|
From:
<br...@ph...> - 2006-05-18 21:08:27
|
Markus Feldmann wrote: > I wanna to execute my batch file, > gnuplot filename.batch > In my batch file i wanna use the filename. Which file name? And what for? |
|
From: Markus F. <fel...@gm...> - 2006-05-22 18:49:33
|
Hans-Bernhard Bröker wrote: > Markus Feldmann wrote: > >> I wanna to execute my batch file, >> gnuplot filename.batch > >> In my batch file i wanna use the filename. > > Which file name? And what for? > 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. This is an wrong example, and i think this doesn't work under gnuplot. But thats my Question. How can i can use such a substitution? mfg Markus |
|
From:
<br...@ph...> - 2006-05-22 20:20:25
|
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 to support command substitution: 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 |
|
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
|
|
From:
<br...@ph...> - 2006-05-23 18:08:28
|
Dave Denholm wrote: > 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 ? That wouldn't help much, I think. He's trying to access the name of the script file currently being executed. That can be literally anywhere in the command line --- I don't see how anyhing in /proc could help finding that, expecially in cases like gnuplot -noraise -persist -mono foo.gpl bar.gpl baz.gpl How is 'bar.gpl' supposed to find its own name in this? If this is to work, it has to be done from inside gnuplot. I.e. there'll have to be a GPVAL_ that exports save_name from inside load_command() to the user. > 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 ? Once you start writing scripts to run from outside gnuplot, I don't think there's much point actually looking at the filename of that script any more, because there no more any reason to establish a link between the name passed to gnuplot (which is, by definition, a script filename) and that of the datafile to be plotted. What's really missing here is not some shell voodoo, but a way of setting gnuplot user-defined variables by startup options, i.e. something like gnuplot -DNAME="foo.dat" foo.gpl If you're going to do that via a wrapper script, you might as well use an existing one, like http://www.phys.uni-paderborn.de/~stern/pl/ (also linked from our homepage). |