|
I realize this is not an Octave question per se, but perhaps someone
here can answer it. My question: How do you change directory in Gnuplot so that your working directory is the directory containing the calling script? I know how to do this in Octave: basedir = fileparts(mfilename("fullpath")); chdir(basedir); I know how to do it in Perl: use FindBin qw($Bin); chdir $Bin; But I don't know how to do it in Gnuplot. Regards, Vic _______________________________________________ Help-octave mailing list [hidden email] https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
On Wed, Nov 26, 2008 at 03:04:53PM -0500, Vic Norton wrote:
> I realize this is not an Octave question per se, but perhaps someone > here can answer it. > > My question: How do you change directory in Gnuplot so that your > working directory is the directory containing the calling script? > > I know how to do this in Octave: > basedir = fileparts(mfilename("fullpath")); > chdir(basedir); > I know how to do it in Perl: > use FindBin qw($Bin); > chdir $Bin; > But I don't know how to do it in Gnuplot. help cd which, btw, works in Octave as well Thomas _______________________________________________ Help-octave mailing list [hidden email] https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
Unfortunately "help cd" is no help, Thomas.
Syntax: cd '<directory-name>' works if you know the directory-name. I want the Gnuplot script to tell me the name of the directory in which it resides. Then the code will be portable. The Octave and Perl segments below do exactly that. The main ingredients have nothing to do with cd or chdir. The main ingredients of the Octave code are fileparts and mfilename. The main ingredient of the Perl code is the FindBin package. Regards, Vic On Nov 26, 2008, at 4:04 PM, Thomas Weber wrote: > On Wed, Nov 26, 2008 at 03:04:53PM -0500, Vic Norton wrote: >> I realize this is not an Octave question per se, but perhaps someone >> here can answer it. >> >> My question: How do you change directory in Gnuplot so that your >> working directory is the directory containing the calling script? >> >> I know how to do this in Octave: >> basedir = fileparts(mfilename("fullpath")); >> chdir(basedir); >> I know how to do it in Perl: >> use FindBin qw($Bin); >> chdir $Bin; >> But I don't know how to do it in Gnuplot. > > help cd > > which, btw, works in Octave as well > > Thomas _______________________________________________ Help-octave mailing list [hidden email] https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
Administrator
|
Do I understand correctly?
You want gnuplot to tell you the directory containing the shell-script that called it? bens-macbook:~ bpabbott$ pwd /Users/bpabbott bens-macbook:~ bpabbott$ gnuplot G N U P L O T Version 4.3 patchlevel 0 last modified November 2008 System: Darwin 9.5.0 Copyright (C) 1986 - 1993, 1998, 2004, 2007, 2008 Thomas Williams, Colin Kelley and many others Type `help` to access the on-line reference manual. The gnuplot FAQ is available from http://www.gnuplot.info/faq/ Send comments and help requests to <gnuplot- [hidden email]> Send bug reports and suggestions to <gnuplot- [hidden email]> Terminal type set to 'x11' gnuplot> pwd /Users/bpabbott gnuplot> I don't see what that has to do with making code portable. Can you be more specific? Ben On Nov 26, 2008, at 7:53 PM, Vic Norton wrote: > Unfortunately "help cd" is no help, Thomas. > Syntax: > cd '<directory-name>' > works if you know the directory-name. I want the Gnuplot script to > tell me the name of the directory in which it resides. Then the code > will be portable. > > The Octave and Perl segments below do exactly that. The main > ingredients have nothing to do with cd or chdir. The main ingredients > of the Octave code are fileparts and mfilename. The main ingredient > of the Perl code is the FindBin package. > > Regards, > > Vic > > On Nov 26, 2008, at 4:04 PM, Thomas Weber wrote: > >> On Wed, Nov 26, 2008 at 03:04:53PM -0500, Vic Norton wrote: >>> I realize this is not an Octave question per se, but perhaps someone >>> here can answer it. >>> >>> My question: How do you change directory in Gnuplot so that your >>> working directory is the directory containing the calling script? >>> >>> I know how to do this in Octave: >>> basedir = fileparts(mfilename("fullpath")); >>> chdir(basedir); >>> I know how to do it in Perl: >>> use FindBin qw($Bin); >>> chdir $Bin; >>> But I don't know how to do it in Gnuplot. >> >> help cd >> >> which, btw, works in Octave as well >> >> Thomas > > _______________________________________________ > Help-octave mailing list > [hidden email] > https://www-old.cae.wisc.edu/mailman/listinfo/help-octave _______________________________________________ Help-octave mailing list [hidden email] https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
In reply to this post by vicnorton
Hello
Perhaps you mention pwd which means 'Present Working Directory' For example gnuplot> pwd /cygdrive/d/usr/Tatsu In octave octave:1> pwd ans = /cygdrive/d/usr/Tatsu Regards Tatsuro --- Vic Norton wrote: > Unfortunately "help cd" is no help, Thomas. > Syntax: > cd '<directory-name>' > works if you know the directory-name. I want the Gnuplot script to > tell me the name of the directory in which it resides. Then the code > will be portable. > > The Octave and Perl segments below do exactly that. The main > ingredients have nothing to do with cd or chdir. The main ingredients > of the Octave code are fileparts and mfilename. The main ingredient > of the Perl code is the FindBin package. > > Regards, > > Vic > > On Nov 26, 2008, at 4:04 PM, Thomas Weber wrote: > > > On Wed, Nov 26, 2008 at 03:04:53PM -0500, Vic Norton wrote: > >> I realize this is not an Octave question per se, but perhaps someone > >> here can answer it. > >> > >> My question: How do you change directory in Gnuplot so that your > >> working directory is the directory containing the calling script? > >> > >> I know how to do this in Octave: > >> basedir = fileparts(mfilename("fullpath")); > >> chdir(basedir); > >> I know how to do it in Perl: > >> use FindBin qw($Bin); > >> chdir $Bin; > >> But I don't know how to do it in Gnuplot. > > > > help cd > > > > which, btw, works in Octave as well > > > > Thomas > > _______________________________________________ > Help-octave mailing list > [hidden email] > https://www-old.cae.wisc.edu/mailman/listinfo/help-octave > -------------------------------------- Power up the Internet with Yahoo! Toolbar. http://pr.mail.yahoo.co.jp/toolbar/ _______________________________________________ Help-octave mailing list [hidden email] https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
In reply to this post by vicnorton
Am Mittwoch, den 26.11.2008, 19:53 -0500 schrieb Vic Norton:
> Unfortunately "help cd" is no help, Thomas. > Syntax: > cd '<directory-name>' > works if you know the directory-name. I want the Gnuplot script to > tell me the name of the directory in which it resides. Then the code > will be portable. Ah, sorry about that. I thought your problem was with changing the directory. Can you elaborate on your use case? I don't think gnuplot has support for that thing, but maybe there's something else. Thomas _______________________________________________ Help-octave mailing list [hidden email] https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
In reply to this post by bpabbott
Am Mittwoch, den 26.11.2008, 20:36 -0500 schrieb Ben Abbott:
> Do I understand correctly? > > You want gnuplot to tell you the directory containing the shell-script > that called it? I think Vic wants the .gpi script to tell where it resides. Say, v.gpi resides in /tmp and has only a pwd statement: $ cat /tmp/v.gpi pwd Now, "load v.gpi" should[1] give him "/tmp/, but gnuplot> load "/tmp/v.gpi" /home/weber Contrast this with Octave's behaviour: octave:1> source "/tmp/v.m" basedir = /tmp where v.m contains the one line from Vic'c first post. [1] By "should" I mean what Vic wants. Thomas _______________________________________________ Help-octave mailing list [hidden email] https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
|
Hi Thomas,
hi Ben, "system" may be your friend: mypath=system ("pwd") cd "/tmp" pwd cd mypath pwd by assigning a variable (mypath in my case) the return value of the system command (in gnuplot) you can remember where you have been. Take care Dieter P.S. tested on linux, gnuplot version 4.2.3 -----Original Message----- > Date: Thu, 27 Nov 2008 08:26:49 +0100 > Subject: Re: A Gnuplot question > From: Thomas Weber <[hidden email]> > To: Ben Abbott <[hidden email]> > Am Mittwoch, den 26.11.2008, 20:36 -0500 schrieb Ben Abbott: > > Do I understand correctly? **** _______________________________________________ Help-octave mailing list [hidden email] https://www-old.cae.wisc.edu/mailman/listinfo/help-octave |
| Powered by Nabble | Edit this page |
