|
From: Alan <ala...@gm...> - 2026-02-25 18:11:09
|
Does Gnuplot offer a system independent way to create directory names relative to the home folder (especially) and also relative to the script folder? I am aware of `system`, but that depends on the OS shell. I'm not a C programmer, but I believe the tricks to retrieve this information in a system independent way are pretty standard. (?) Thank you. |
|
From: Peter R. <p.r...@sh...> - 2026-02-26 12:34:06
|
Not totally clear of the objective here, but FWIW, you can specify a path using "./abc/efg/hij" (i.e. using a forward slash) on both Windows /and/ Unix/Linux, whereas Unix does not understand the '\' character in this context. So the forward slash is system independent. P. On 25/02/2026 18:10, Alan wrote: > Does Gnuplot offer a system independent way to > create directory names relative to the home folder (especially) > and also relative to the script folder? > > I am aware of `system`, but that depends on the OS shell. > I'm not a C programmer, but I believe the tricks to retrieve this > information in a system independent way are pretty standard. (?) > > Thank you. > > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > Membership management via:https://lists.sourceforge.net/lists/listinfo/gnuplot-info |
|
From: Alan <ala...@gm...> - 2026-02-26 14:13:05
|
I would like to have data stored both relative to the script file and more importantly relative to the home directory, and I would like an easy way to find the data on multiple systems where the same relative relationships hold. Most important is being able to find the home directory in the gnuplot script in a system independent way. For example, I'd like my home and work computers to have an output folder that is fixed relative to the home directory, and I'd like Gnuplot to be able to find it without relying on `system`, which requires a different commands depending on the shell. (Powershell or cmd on Windows, vs zsh on Mac, vs bash or dash on Linux, etc.) Also desirable is for the script to be able to find data relative to the script's location, no matter what the current working directory from which Gnuplot is launched. As a simple example, suppose I am in folder `a` and do gnuplot ./gnuplot/myscript.gpi Then the pwd for Gnuplot becomes `a`, not the script directory. In the script, I'd like to ask Gnuplot for the script directory. Hope that's clearer, Alan On Thu, Feb 26, 2026 at 7:34 AM Peter Rockett via gnuplot-info < gnu...@li...> wrote: > Not totally clear of the objective here, but FWIW, you can specify a > path using "./abc/efg/hij" (i.e. using a forward slash) on both Windows > /and/ Unix/Linux, whereas Unix does not understand the '\' character in > this context. So the forward slash is system independent. > > P. > > On 25/02/2026 18:10, Alan wrote: > > Does Gnuplot offer a system independent way to > > create directory names relative to the home folder (especially) > > and also relative to the script folder? > > > > I am aware of `system`, but that depends on the OS shell. > > I'm not a C programmer, but I believe the tricks to retrieve this > > information in a system independent way are pretty standard. (?) > > > > Thank you. > > > > _______________________________________________ > > gnuplot-info mailing list > > gnu...@li... > > Membership management via: > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > Membership management via: > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > |
|
From: Alan <ala...@gm...> - 2026-02-26 18:05:59
|
Thanks for helping to look for a workaround, but I do not think so. Too many different computers and people involved. Let me ask this differently. According to the manual (p.64), "The program then looks in the user’s HOME directory". So after launching, Gnuplot has already determined the location of the home directory. Is there any way to ask Gnuplot for its value (as a string)? If not, is there any reason for developers to avoid adding such a feature? Thanks, Alan On Thu, Feb 26, 2026 at 10:51 AM Peter Rockett <p.r...@sh...> wrote: > OK. Is the GNUPLOT_LIB environment variable what you need? Or the > .gnuplot & GNUPLOT.INI startup files? > > P. > > On 26/02/2026 14:12, Alan wrote: > > I would like to have data stored both > > relative to the script file and more importantly relative to the home > > directory, > > and I would like an easy way to find the data on multiple systems > > where the same relative relationships hold. > > > > Most important is being able to find the home directory > > in the gnuplot script in a system independent way. > > For example, I'd like my home and work computers > > to have an output folder that is fixed relative to the home directory, > > and I'd like Gnuplot to be able to find it without relying on `system`, > > which requires a different commands depending on the shell. > > (Powershell or cmd on Windows, vs zsh on Mac, vs bash or dash on Linux, > > etc.) > > > > Also desirable is for the script to be able to find data > > relative to the script's location, no matter what the > > current working directory from which Gnuplot is launched. > > As a simple example, suppose I am in folder `a` and do > > gnuplot ./gnuplot/myscript.gpi > > Then the pwd for Gnuplot becomes `a`, not the script directory. > > In the script, I'd like to ask Gnuplot for the script directory. > > > > Hope that's clearer, Alan > > > > On Thu, Feb 26, 2026 at 7:34 AM Peter Rockett via gnuplot-info < > > gnu...@li...> wrote: > > > >> Not totally clear of the objective here, but FWIW, you can specify a > >> path using "./abc/efg/hij" (i.e. using a forward slash) on both Windows > >> /and/ Unix/Linux, whereas Unix does not understand the '\' character in > >> this context. So the forward slash is system independent. > >> > >> P. > >> > >> On 25/02/2026 18:10, Alan wrote: > >>> Does Gnuplot offer a system independent way to > >>> create directory names relative to the home folder (especially) > >>> and also relative to the script folder? > >>> > >>> I am aware of `system`, but that depends on the OS shell. > >>> I'm not a C programmer, but I believe the tricks to retrieve this > >>> information in a system independent way are pretty standard. (?) > >>> > >>> Thank you. > >>> > >>> _______________________________________________ > >>> gnuplot-info mailing list > >>> gnu...@li... > >>> Membership management via: > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info > >> _______________________________________________ > >> gnuplot-info mailing list > >> gnu...@li... > >> Membership management via: > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info > >> > > _______________________________________________ > > gnuplot-info mailing list > > gnu...@li... > > Membership management via: > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > |
|
From: Michael S. <Mic...@bo...> - 2026-02-26 18:46:16
|
How about this? michael@argon:~/tmp$ cat p.gnu home = "dogrun" print home home = "`echo $HOME`" print home michael@argon:~/tmp$ gnuplot p.gnu dogrun /home/michael On Thu, Feb 26, 2026 at 10:06 AM Alan <ala...@gm...> wrote: > Thanks for helping to look for a workaround, but I do not think so. > > Too many different computers and people involved. > > Let me ask this differently. > According to the manual (p.64), "The program then looks in the user’s HOME > directory". > So after launching, Gnuplot has already determined the location of the home > directory. > Is there any way to ask Gnuplot for its value (as a string)? > If not, is there any reason for developers to avoid adding such a feature? > > Thanks, Alan > > On Thu, Feb 26, 2026 at 10:51 AM Peter Rockett <p.r...@sh...> > wrote: > > > OK. Is the GNUPLOT_LIB environment variable what you need? Or the > > .gnuplot & GNUPLOT.INI startup files? > > > > P. > > > > On 26/02/2026 14:12, Alan wrote: > > > I would like to have data stored both > > > relative to the script file and more importantly relative to the home > > > directory, > > > and I would like an easy way to find the data on multiple systems > > > where the same relative relationships hold. > > > > > > Most important is being able to find the home directory > > > in the gnuplot script in a system independent way. > > > For example, I'd like my home and work computers > > > to have an output folder that is fixed relative to the home directory, > > > and I'd like Gnuplot to be able to find it without relying on `system`, > > > which requires a different commands depending on the shell. > > > (Powershell or cmd on Windows, vs zsh on Mac, vs bash or dash on Linux, > > > etc.) > > > > > > Also desirable is for the script to be able to find data > > > relative to the script's location, no matter what the > > > current working directory from which Gnuplot is launched. > > > As a simple example, suppose I am in folder `a` and do > > > gnuplot ./gnuplot/myscript.gpi > > > Then the pwd for Gnuplot becomes `a`, not the script directory. > > > In the script, I'd like to ask Gnuplot for the script directory. > > > > > > Hope that's clearer, Alan > > > > > > On Thu, Feb 26, 2026 at 7:34 AM Peter Rockett via gnuplot-info < > > > gnu...@li...> wrote: > > > > > >> Not totally clear of the objective here, but FWIW, you can specify a > > >> path using "./abc/efg/hij" (i.e. using a forward slash) on both > Windows > > >> /and/ Unix/Linux, whereas Unix does not understand the '\' character > in > > >> this context. So the forward slash is system independent. > > >> > > >> P. > > >> > > >> On 25/02/2026 18:10, Alan wrote: > > >>> Does Gnuplot offer a system independent way to > > >>> create directory names relative to the home folder (especially) > > >>> and also relative to the script folder? > > >>> > > >>> I am aware of `system`, but that depends on the OS shell. > > >>> I'm not a C programmer, but I believe the tricks to retrieve this > > >>> information in a system independent way are pretty standard. (?) > > >>> > > >>> Thank you. > > >>> > > >>> _______________________________________________ > > >>> gnuplot-info mailing list > > >>> gnu...@li... > > >>> Membership management via: > > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info > > >> _______________________________________________ > > >> gnuplot-info mailing list > > >> gnu...@li... > > >> Membership management via: > > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info > > >> > > > _______________________________________________ > > > gnuplot-info mailing list > > > gnu...@li... > > > Membership management via: > > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > > > > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > Membership management via: > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > |
|
From: Alan <ala...@gm...> - 2026-02-26 19:23:36
|
I believe (?) your suggestion is equivalent to using `system`, so it is not a cross-platform solution. E.g., on Windows: gnuplot> print "`echo $HOME`" $HOME (Note that $HOME is valid in PowerShell, but sadly cmd remains the Windows default shell, and changing that remains fraught.) On Thu, Feb 26, 2026 at 1:46 PM Michael Schuh < Mic...@bo...> wrote: > How about this? > > michael@argon:~/tmp$ cat p.gnu > home = "dogrun" > print home > home = "`echo $HOME`" > print home > > > michael@argon:~/tmp$ gnuplot p.gnu > dogrun > /home/michael > > On Thu, Feb 26, 2026 at 10:06 AM Alan <ala...@gm...> wrote: > >> Thanks for helping to look for a workaround, but I do not think so. >> >> Too many different computers and people involved. >> >> Let me ask this differently. >> According to the manual (p.64), "The program then looks in the user’s HOME >> directory". >> So after launching, Gnuplot has already determined the location of the >> home >> directory. >> Is there any way to ask Gnuplot for its value (as a string)? >> If not, is there any reason for developers to avoid adding such a feature? >> >> Thanks, Alan >> >> On Thu, Feb 26, 2026 at 10:51 AM Peter Rockett <p.r...@sh... >> > >> wrote: >> >> > OK. Is the GNUPLOT_LIB environment variable what you need? Or the >> > .gnuplot & GNUPLOT.INI startup files? >> > >> > P. >> > >> > On 26/02/2026 14:12, Alan wrote: >> > > I would like to have data stored both >> > > relative to the script file and more importantly relative to the home >> > > directory, >> > > and I would like an easy way to find the data on multiple systems >> > > where the same relative relationships hold. >> > > >> > > Most important is being able to find the home directory >> > > in the gnuplot script in a system independent way. >> > > For example, I'd like my home and work computers >> > > to have an output folder that is fixed relative to the home directory, >> > > and I'd like Gnuplot to be able to find it without relying on >> `system`, >> > > which requires a different commands depending on the shell. >> > > (Powershell or cmd on Windows, vs zsh on Mac, vs bash or dash on >> Linux, >> > > etc.) >> > > >> > > Also desirable is for the script to be able to find data >> > > relative to the script's location, no matter what the >> > > current working directory from which Gnuplot is launched. >> > > As a simple example, suppose I am in folder `a` and do >> > > gnuplot ./gnuplot/myscript.gpi >> > > Then the pwd for Gnuplot becomes `a`, not the script directory. >> > > In the script, I'd like to ask Gnuplot for the script directory. >> > > >> > > Hope that's clearer, Alan >> > > >> > > On Thu, Feb 26, 2026 at 7:34 AM Peter Rockett via gnuplot-info < >> > > gnu...@li...> wrote: >> > > >> > >> Not totally clear of the objective here, but FWIW, you can specify a >> > >> path using "./abc/efg/hij" (i.e. using a forward slash) on both >> Windows >> > >> /and/ Unix/Linux, whereas Unix does not understand the '\' character >> in >> > >> this context. So the forward slash is system independent. >> > >> >> > >> P. >> > >> >> > >> On 25/02/2026 18:10, Alan wrote: >> > >>> Does Gnuplot offer a system independent way to >> > >>> create directory names relative to the home folder (especially) >> > >>> and also relative to the script folder? >> > >>> >> > >>> I am aware of `system`, but that depends on the OS shell. >> > >>> I'm not a C programmer, but I believe the tricks to retrieve this >> > >>> information in a system independent way are pretty standard. (?) >> > >>> >> > >>> Thank you. >> > >>> >> > >>> _______________________________________________ >> > >>> gnuplot-info mailing list >> > >>> gnu...@li... >> > >>> Membership management via: >> > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info >> > >> _______________________________________________ >> > >> gnuplot-info mailing list >> > >> gnu...@li... >> > >> Membership management via: >> > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info >> > >> >> > > _______________________________________________ >> > > gnuplot-info mailing list >> > > gnu...@li... >> > > Membership management via: >> > https://lists.sourceforge.net/lists/listinfo/gnuplot-info >> > >> >> _______________________________________________ >> gnuplot-info mailing list >> gnu...@li... >> Membership management via: >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info >> > |
|
From: Michael S. <Mic...@bo...> - 2026-02-26 19:28:25
|
Correct, I wrote and tested my suggestion on a Debian system. I didn't test it on a Windows system. Unfortunately, it sounds like my suggestion will not work as written on a Windows system. Michael On Thu, Feb 26, 2026 at 11:23 AM Alan <ala...@gm...> wrote: > I believe (?) your suggestion is equivalent to using `system`, > so it is not a cross-platform solution. E.g., on Windows: > > gnuplot> print "`echo $HOME`" > $HOME > > (Note that $HOME is valid in PowerShell, but sadly > cmd remains the Windows default shell, and changing > that remains fraught.) > > > > On Thu, Feb 26, 2026 at 1:46 PM Michael Schuh < > Mic...@bo...> wrote: > > > How about this? > > > > michael@argon:~/tmp$ cat p.gnu > > home = "dogrun" > > print home > > home = "`echo $HOME`" > > print home > > > > > > michael@argon:~/tmp$ gnuplot p.gnu > > dogrun > > /home/michael > > > > On Thu, Feb 26, 2026 at 10:06 AM Alan <ala...@gm...> wrote: > > > >> Thanks for helping to look for a workaround, but I do not think so. > >> > >> Too many different computers and people involved. > >> > >> Let me ask this differently. > >> According to the manual (p.64), "The program then looks in the user’s > HOME > >> directory". > >> So after launching, Gnuplot has already determined the location of the > >> home > >> directory. > >> Is there any way to ask Gnuplot for its value (as a string)? > >> If not, is there any reason for developers to avoid adding such a > feature? > >> > >> Thanks, Alan > >> > >> On Thu, Feb 26, 2026 at 10:51 AM Peter Rockett < > p.r...@sh... > >> > > >> wrote: > >> > >> > OK. Is the GNUPLOT_LIB environment variable what you need? Or the > >> > .gnuplot & GNUPLOT.INI startup files? > >> > > >> > P. > >> > > >> > On 26/02/2026 14:12, Alan wrote: > >> > > I would like to have data stored both > >> > > relative to the script file and more importantly relative to the > home > >> > > directory, > >> > > and I would like an easy way to find the data on multiple systems > >> > > where the same relative relationships hold. > >> > > > >> > > Most important is being able to find the home directory > >> > > in the gnuplot script in a system independent way. > >> > > For example, I'd like my home and work computers > >> > > to have an output folder that is fixed relative to the home > directory, > >> > > and I'd like Gnuplot to be able to find it without relying on > >> `system`, > >> > > which requires a different commands depending on the shell. > >> > > (Powershell or cmd on Windows, vs zsh on Mac, vs bash or dash on > >> Linux, > >> > > etc.) > >> > > > >> > > Also desirable is for the script to be able to find data > >> > > relative to the script's location, no matter what the > >> > > current working directory from which Gnuplot is launched. > >> > > As a simple example, suppose I am in folder `a` and do > >> > > gnuplot ./gnuplot/myscript.gpi > >> > > Then the pwd for Gnuplot becomes `a`, not the script directory. > >> > > In the script, I'd like to ask Gnuplot for the script directory. > >> > > > >> > > Hope that's clearer, Alan > >> > > > >> > > On Thu, Feb 26, 2026 at 7:34 AM Peter Rockett via gnuplot-info < > >> > > gnu...@li...> wrote: > >> > > > >> > >> Not totally clear of the objective here, but FWIW, you can specify > a > >> > >> path using "./abc/efg/hij" (i.e. using a forward slash) on both > >> Windows > >> > >> /and/ Unix/Linux, whereas Unix does not understand the '\' > character > >> in > >> > >> this context. So the forward slash is system independent. > >> > >> > >> > >> P. > >> > >> > >> > >> On 25/02/2026 18:10, Alan wrote: > >> > >>> Does Gnuplot offer a system independent way to > >> > >>> create directory names relative to the home folder (especially) > >> > >>> and also relative to the script folder? > >> > >>> > >> > >>> I am aware of `system`, but that depends on the OS shell. > >> > >>> I'm not a C programmer, but I believe the tricks to retrieve this > >> > >>> information in a system independent way are pretty standard. (?) > >> > >>> > >> > >>> Thank you. > >> > >>> > >> > >>> _______________________________________________ > >> > >>> gnuplot-info mailing list > >> > >>> gnu...@li... > >> > >>> Membership management via: > >> > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info > >> > >> _______________________________________________ > >> > >> gnuplot-info mailing list > >> > >> gnu...@li... > >> > >> Membership management via: > >> > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info > >> > >> > >> > > _______________________________________________ > >> > > gnuplot-info mailing list > >> > > gnu...@li... > >> > > Membership management via: > >> > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > >> > > >> > >> _______________________________________________ > >> gnuplot-info mailing list > >> gnu...@li... > >> Membership management via: > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info > >> > > > > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > Membership management via: > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > |
|
From: Philipp K. J. <ja...@ie...> - 2026-02-26 19:45:30
|
On Thu, 26 Feb 2026 14:22:58 -0500 Alan <ala...@gm...> wrote: Have you checked out the built-in "pwd" command? > I believe (?) your suggestion is equivalent to using `system`, > so it is not a cross-platform solution. E.g., on Windows: > > gnuplot> print "`echo $HOME`" > $HOME > > (Note that $HOME is valid in PowerShell, but sadly > cmd remains the Windows default shell, and changing > that remains fraught.) > > > > On Thu, Feb 26, 2026 at 1:46 PM Michael Schuh < > Mic...@bo...> wrote: > > > How about this? > > > > michael@argon:~/tmp$ cat p.gnu > > home = "dogrun" > > print home > > home = "`echo $HOME`" > > print home > > > > > > michael@argon:~/tmp$ gnuplot p.gnu > > dogrun > > /home/michael > > > > On Thu, Feb 26, 2026 at 10:06 AM Alan <ala...@gm...> wrote: > > > >> Thanks for helping to look for a workaround, but I do not think so. > >> > >> Too many different computers and people involved. > >> > >> Let me ask this differently. > >> According to the manual (p.64), "The program then looks in the > >> user’s HOME directory". > >> So after launching, Gnuplot has already determined the location of > >> the home > >> directory. > >> Is there any way to ask Gnuplot for its value (as a string)? > >> If not, is there any reason for developers to avoid adding such a > >> feature? > >> > >> Thanks, Alan > >> > >> On Thu, Feb 26, 2026 at 10:51 AM Peter Rockett > >> <p.r...@sh... > >> > > >> wrote: > >> > >> > OK. Is the GNUPLOT_LIB environment variable what you need? Or the > >> > .gnuplot & GNUPLOT.INI startup files? > >> > > >> > P. > >> > > >> > On 26/02/2026 14:12, Alan wrote: > >> > > I would like to have data stored both > >> > > relative to the script file and more importantly relative to > >> > > the home directory, > >> > > and I would like an easy way to find the data on multiple > >> > > systems where the same relative relationships hold. > >> > > > >> > > Most important is being able to find the home directory > >> > > in the gnuplot script in a system independent way. > >> > > For example, I'd like my home and work computers > >> > > to have an output folder that is fixed relative to the home > >> > > directory, and I'd like Gnuplot to be able to find it without > >> > > relying on > >> `system`, > >> > > which requires a different commands depending on the shell. > >> > > (Powershell or cmd on Windows, vs zsh on Mac, vs bash or dash > >> > > on > >> Linux, > >> > > etc.) > >> > > > >> > > Also desirable is for the script to be able to find data > >> > > relative to the script's location, no matter what the > >> > > current working directory from which Gnuplot is launched. > >> > > As a simple example, suppose I am in folder `a` and do > >> > > gnuplot ./gnuplot/myscript.gpi > >> > > Then the pwd for Gnuplot becomes `a`, not the script directory. > >> > > In the script, I'd like to ask Gnuplot for the script > >> > > directory. > >> > > > >> > > Hope that's clearer, Alan > >> > > > >> > > On Thu, Feb 26, 2026 at 7:34 AM Peter Rockett via gnuplot-info > >> > > < gnu...@li...> wrote: > >> > > > >> > >> Not totally clear of the objective here, but FWIW, you can > >> > >> specify a path using "./abc/efg/hij" (i.e. using a forward > >> > >> slash) on both > >> Windows > >> > >> /and/ Unix/Linux, whereas Unix does not understand the '\' > >> > >> character > >> in > >> > >> this context. So the forward slash is system independent. > >> > >> > >> > >> P. > >> > >> > >> > >> On 25/02/2026 18:10, Alan wrote: > >> > >>> Does Gnuplot offer a system independent way to > >> > >>> create directory names relative to the home folder > >> > >>> (especially) and also relative to the script folder? > >> > >>> > >> > >>> I am aware of `system`, but that depends on the OS shell. > >> > >>> I'm not a C programmer, but I believe the tricks to retrieve > >> > >>> this information in a system independent way are pretty > >> > >>> standard. (?) > >> > >>> > >> > >>> Thank you. > >> > >>> > >> > >>> _______________________________________________ > >> > >>> gnuplot-info mailing list > >> > >>> gnu...@li... > >> > >>> Membership management via: > >> > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info > >> > >> _______________________________________________ > >> > >> gnuplot-info mailing list > >> > >> gnu...@li... > >> > >> Membership management via: > >> > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info > >> > >> > >> > > _______________________________________________ > >> > > gnuplot-info mailing list > >> > > gnu...@li... > >> > > Membership management via: > >> > https://lists.sourceforge.net/lists/listinfo/gnuplot-info > >> > > >> > >> _______________________________________________ > >> gnuplot-info mailing list > >> gnu...@li... > >> Membership management via: > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info > >> > > > > _______________________________________________ > gnuplot-info mailing list > gnu...@li... > Membership management via: > https://lists.sourceforge.net/lists/listinfo/gnuplot-info |
|
From: Ethan M. <eam...@gm...> - 2026-02-26 19:36:28
|
Gnuplot uses the linux/unix convention that ~ (tilde) represents the user's
home directory.
This is taken from the environmental variable HOME on linux and USERPROFILE
on windows.
So
gnuplot> load "~/myscript.gp"
loads myscript.gp from the user's home directory.
gnuplot> set print "~/sub/output.txt"
gnuplot> print "# New script"
gnuplot> print "# that doesn't do anything"
gnuplot> unset output
will create and write to a new file in a subdirectory of the user's HOME
directory.
Ethan
On Thu, Feb 26, 2026 at 10:06 AM Alan <ala...@gm...> wrote:
> Thanks for helping to look for a workaround, but I do not think so.
>
> Too many different computers and people involved.
>
> Let me ask this differently.
> According to the manual (p.64), "The program then looks in the user’s HOME
> directory".
> So after launching, Gnuplot has already determined the location of the home
> directory.
> Is there any way to ask Gnuplot for its value (as a string)?
> If not, is there any reason for developers to avoid adding such a feature?
>
> Thanks, Alan
>
> On Thu, Feb 26, 2026 at 10:51 AM Peter Rockett <p.r...@sh...>
> wrote:
>
> > OK. Is the GNUPLOT_LIB environment variable what you need? Or the
> > .gnuplot & GNUPLOT.INI startup files?
> >
> > P.
> >
> > On 26/02/2026 14:12, Alan wrote:
> > > I would like to have data stored both
> > > relative to the script file and more importantly relative to the home
> > > directory,
> > > and I would like an easy way to find the data on multiple systems
> > > where the same relative relationships hold.
> > >
> > > Most important is being able to find the home directory
> > > in the gnuplot script in a system independent way.
> > > For example, I'd like my home and work computers
> > > to have an output folder that is fixed relative to the home directory,
> > > and I'd like Gnuplot to be able to find it without relying on `system`,
> > > which requires a different commands depending on the shell.
> > > (Powershell or cmd on Windows, vs zsh on Mac, vs bash or dash on Linux,
> > > etc.)
> > >
> > > Also desirable is for the script to be able to find data
> > > relative to the script's location, no matter what the
> > > current working directory from which Gnuplot is launched.
> > > As a simple example, suppose I am in folder `a` and do
> > > gnuplot ./gnuplot/myscript.gpi
> > > Then the pwd for Gnuplot becomes `a`, not the script directory.
> > > In the script, I'd like to ask Gnuplot for the script directory.
> > >
> > > Hope that's clearer, Alan
> > >
> > > On Thu, Feb 26, 2026 at 7:34 AM Peter Rockett via gnuplot-info <
> > > gnu...@li...> wrote:
> > >
> > >> Not totally clear of the objective here, but FWIW, you can specify a
> > >> path using "./abc/efg/hij" (i.e. using a forward slash) on both
> Windows
> > >> /and/ Unix/Linux, whereas Unix does not understand the '\' character
> in
> > >> this context. So the forward slash is system independent.
> > >>
> > >> P.
> > >>
> > >> On 25/02/2026 18:10, Alan wrote:
> > >>> Does Gnuplot offer a system independent way to
> > >>> create directory names relative to the home folder (especially)
> > >>> and also relative to the script folder?
> > >>>
> > >>> I am aware of `system`, but that depends on the OS shell.
> > >>> I'm not a C programmer, but I believe the tricks to retrieve this
> > >>> information in a system independent way are pretty standard. (?)
> > >>>
> > >>> Thank you.
> > >>>
> > >>> _______________________________________________
> > >>> gnuplot-info mailing list
> > >>> gnu...@li...
> > >>> Membership management via:
> > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info
> > >> _______________________________________________
> > >> gnuplot-info mailing list
> > >> gnu...@li...
> > >> Membership management via:
> > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info
> > >>
> > > _______________________________________________
> > > gnuplot-info mailing list
> > > gnu...@li...
> > > Membership management via:
> > https://lists.sourceforge.net/lists/listinfo/gnuplot-info
> >
>
> _______________________________________________
> gnuplot-info mailing list
> gnu...@li...
> Membership management via:
> https://lists.sourceforge.net/lists/listinfo/gnuplot-info
>
|
|
From: Alan <ala...@gm...> - 2026-02-26 20:54:00
|
Hello Ethan, Thank you very much for noticing this thread! Your solution does not work for me on Windows, for two separate reasons. First of all, although Windows honors the forward slash as a path separator (even cmd does!), it seems Gnuplot doesn't always do path normalization, so using the tilde in a forward slashed path on Windows fails. Yet for shared scripts, of course I want to use the more standard forward slash. Second of all, if I do start a backslashed (i.e., Windows style) path with a tilde, Gnuplot expands the tilde not to my home directory but rather to my AppData\Roaming directory. I would like access to the actual user home directory. Thank you again for your help. Alan Isaac On Thu, Feb 26, 2026 at 2:36 PM Ethan Merritt <eam...@gm...> wrote: > Gnuplot uses the linux/unix convention that ~ (tilde) represents the > user's home directory. > This is taken from the environmental variable HOME on linux and > USERPROFILE on windows. > So > gnuplot> load "~/myscript.gp" > loads myscript.gp from the user's home directory. > gnuplot> set print "~/sub/output.txt" > gnuplot> print "# New script" > gnuplot> print "# that doesn't do anything" > gnuplot> unset output > will create and write to a new file in a subdirectory of the user's HOME > directory. > > Ethan > > > > On Thu, Feb 26, 2026 at 10:06 AM Alan <ala...@gm...> wrote: > >> Thanks for helping to look for a workaround, but I do not think so. >> >> Too many different computers and people involved. >> >> Let me ask this differently. >> According to the manual (p.64), "The program then looks in the user’s HOME >> directory". >> So after launching, Gnuplot has already determined the location of the >> home >> directory. >> Is there any way to ask Gnuplot for its value (as a string)? >> If not, is there any reason for developers to avoid adding such a feature? >> >> Thanks, Alan >> >> On Thu, Feb 26, 2026 at 10:51 AM Peter Rockett <p.r...@sh... >> > >> wrote: >> >> > OK. Is the GNUPLOT_LIB environment variable what you need? Or the >> > .gnuplot & GNUPLOT.INI startup files? >> > >> > P. >> > >> > On 26/02/2026 14:12, Alan wrote: >> > > I would like to have data stored both >> > > relative to the script file and more importantly relative to the home >> > > directory, >> > > and I would like an easy way to find the data on multiple systems >> > > where the same relative relationships hold. >> > > >> > > Most important is being able to find the home directory >> > > in the gnuplot script in a system independent way. >> > > For example, I'd like my home and work computers >> > > to have an output folder that is fixed relative to the home directory, >> > > and I'd like Gnuplot to be able to find it without relying on >> `system`, >> > > which requires a different commands depending on the shell. >> > > (Powershell or cmd on Windows, vs zsh on Mac, vs bash or dash on >> Linux, >> > > etc.) >> > > >> > > Also desirable is for the script to be able to find data >> > > relative to the script's location, no matter what the >> > > current working directory from which Gnuplot is launched. >> > > As a simple example, suppose I am in folder `a` and do >> > > gnuplot ./gnuplot/myscript.gpi >> > > Then the pwd for Gnuplot becomes `a`, not the script directory. >> > > In the script, I'd like to ask Gnuplot for the script directory. >> > > >> > > Hope that's clearer, Alan >> > > >> > > On Thu, Feb 26, 2026 at 7:34 AM Peter Rockett via gnuplot-info < >> > > gnu...@li...> wrote: >> > > >> > >> Not totally clear of the objective here, but FWIW, you can specify a >> > >> path using "./abc/efg/hij" (i.e. using a forward slash) on both >> Windows >> > >> /and/ Unix/Linux, whereas Unix does not understand the '\' character >> in >> > >> this context. So the forward slash is system independent. >> > >> >> > >> P. >> > >> >> > >> On 25/02/2026 18:10, Alan wrote: >> > >>> Does Gnuplot offer a system independent way to >> > >>> create directory names relative to the home folder (especially) >> > >>> and also relative to the script folder? >> > >>> >> > >>> I am aware of `system`, but that depends on the OS shell. >> > >>> I'm not a C programmer, but I believe the tricks to retrieve this >> > >>> information in a system independent way are pretty standard. (?) >> > >>> >> > >>> Thank you. >> > >>> >> > >>> _______________________________________________ >> > >>> gnuplot-info mailing list >> > >>> gnu...@li... >> > >>> Membership management via: >> > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info >> > >> _______________________________________________ >> > >> gnuplot-info mailing list >> > >> gnu...@li... >> > >> Membership management via: >> > >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info >> > >> >> > > _______________________________________________ >> > > gnuplot-info mailing list >> > > gnu...@li... >> > > Membership management via: >> > https://lists.sourceforge.net/lists/listinfo/gnuplot-info >> > >> >> _______________________________________________ >> gnuplot-info mailing list >> gnu...@li... >> Membership management via: >> https://lists.sourceforge.net/lists/listinfo/gnuplot-info >> > |
|
From: theozh <th...@gm...> - 2026-02-27 08:39:41
|
what about an if/else statement? Something like...
myHomeDir = GPVAL_SYSNAME[1:7] eq "Windows" ? system("echo %userprofile%") : system("echo ~")
Maybe you could also use the gnuplot variable GPVAL_PWD instead, which is the current working directory, but not necessarily the home directory.
|