help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shell script location


From: RC Crozier
Subject: Re: shell script location
Date: Tue, 08 Jan 2013 17:51:04 +0000

Quoting Jordi GutiƩrrez Hermoso <address@hidden> on Tue, 8 Jan 2013 12:35:44 -0500:

On 8 January 2013 11:09, Richard Crozier <address@hidden> wrote:
I'm trying out running an octave script as an executeable program
(http://sunsite.univie.ac.at/textbooks/octave/octave_3.html#SEC39)

is there any way for octave running this way to get the location of
the running script? I want it to be able to locate other function
files from the script location (actually I just want to cd to the
script location, knowing the other function files are located there
too), but mfilename() returns an empty string. I'm guession this is
because this is not actually treated as a script file, but as a
series of commands to the interpreter.

WFM, what OS are you using and what Octave version?

    address@hidden:~$ ./lol.m
    ans = lol
    ans = /home/jordi/lol
    ans = /home/jordi/lol.m

    address@hidden:~$ cat lol.m
    #!/usr/local/bin/octave -q
    mfilename
    mfilename fullpath
    mfilename fullpathext

- Jordi G. H.



Actually your script worked fine for me. Turns out I was asking the wrong question, the real problem is finding the location of the file using 'which', not getting it's name:

bash-4.1$ cat ./temp/lol.m
#! /home/s0237326/bin/share/bin/octave -qf

which(mfilename)
whos mfilename
disp(which(mfilename))
bash-4.1$ ./temp/lol.m

bash-4.1$


I'm using Scientific Linux 6.something and Octave 3.6.2 compiled and installed locally from the official release sources.

Richard




--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]