FAQ: Difference between revisions

Jump to navigation Jump to search
21 bytes added ,  16 November 2012
Line 385: Line 385:
To execute a script from within Octave, just type its name without the .m extension. So, if you have a script called <code>foo.m</code>, just type <code>foo</code> from within Octave to execute. You have to make sure that the script is in your current path. Type <code>path</code> in Octave to see what this path is.
To execute a script from within Octave, just type its name without the .m extension. So, if you have a script called <code>foo.m</code>, just type <code>foo</code> from within Octave to execute. You have to make sure that the script is in your current path. Type <code>path</code> in Octave to see what this path is.


If the script name has characters that are not valid for an Octave identifier, or if you do not want to use addpath to add the script's location to the current path, you can use the run function instead:
If the script name has characters that are not valid for an Octave identifier, or if you do not want to use addpath to add the script's location to the current path, you can use the <code>run</code> function instead:


   octave> run("Script Name With Spaces.m")
   octave> run("Script Name With Spaces.m")
Line 394: Line 394:
   $ octave the-script.m arg1 arg2
   $ octave the-script.m arg1 arg2


In a Unix environment, if the script has a [http://en.wikipedia.org/wiki/Shebang_%28Unix%29 shebang] (e.g. <code>#!/usr/bin/octave) and executable permissions, you can call it like any other Unix program with arguments:
In a Unix environment, if the script has a [http://en.wikipedia.org/wiki/Shebang_%28Unix%29 shebang] (e.g. <code>#!/usr/bin/octave</code>) and executable permissions, you can call it like any other Unix program with arguments:


    ./the-script arg1 arg2
  $ ./the-script arg1 arg2


If you call the script from the shell and it's plotting, please note how to plot when running a script from the shell.
If you call the script from the shell and it's plotting, please note how to plot when running a script from the shell.

Navigation menu