Go to the first, previous, next, last section, table of contents.


Invoking Octave

Normally, Octave is used interactively by running the program `octave' without any arguments. Once started, Octave reads commands from the terminal until you tell it to exit.

You can also specify the name of a file on the command line, and Octave will read and execute the commands from the named file and then exit when it is finished.

You can further control how Octave starts up by using the command-line options described in the next section, and Octave itself can remind you of the options available. Type

octave --help

to display all available options and briefly describe their use (`octave -h' is a shorter equivalent).

Command Line Options

--debug
-d
Enter parser debugging mode. Using this option will cause Octave's parser to print a lot of information about the commands it reads, and is probably only useful if you are actually trying to debug the parser.
--echo-commands
-x
Echo commands as they are executed.
--exec-path path
Specify the path to search for programs to run. The value of path specified on the command line will override any value of `OCTAVE_EXEC_PATH' found in the environment, but not any `EXEC_PATH = "path"' commands found in the system or user startup files.
--help
-h
-?
Print short help message and exit.
--info-file filename
Specify the name of the info file to use. The value of filename specified on the command line will override any value of `OCTAVE_INFO_FILE' found in the environment, but not any `INFO_FILE = "filename"' commands found in the system or user startup files.
--info-program program
Specify the name of the info program to use. The value of program specified on the command line will override any value of `OCTAVE_INFO_PROGRAM' found in the environment, but not any `INFO_PROGRAM = "program"' commands found in the system or user startup files.
--interactive
-i
Force interactive behavior.
--no-init-file
Don't read the `~/.octaverc' or `.octaverc' files.
--no-line-editing
Disable command-line editing and history.
--no-site-file
Don't read the site-wide `octaverc' file.
--norc
-f
Don't read any of the system or user initialization files at startup. This is equivalent to using both of the options --no-init-file and --no-site-file.
--path path
-p path
Specify the path to search for function files. The value of path specified on the command line will override any value of `OCTAVE_PATH' found in the environment, but not any `LOADPATH = "path"' commands found in the system or user startup files.
--silent
--quiet
-q
Don't print message at startup.
--traditional
--braindead
Set initial values for user-preference variables to the following values for compatibility with MATLAB.
PS1                           = ">> "
PS2                           = ""
beep_on_error                 = 1
default_save_format           = "mat-binary"
define_all_return_values      = 1
do_fortran_indexing           = 1
empty_list_elements_ok        = 1
implicit_str_to_num_ok        = 1
ok_to_lose_imaginary_part     = 1
page_screen_output            = 0
prefer_column_vectors         = 0
prefer_zero_one_indexing      = 1
print_empty_dimensions        = 0
treat_neg_dim_as_zero         = 1
warn_function_name_clash      = 0
whitespace_in_literal_matrix  = "traditional"
--verbose
-V
Turn on verbose output.
--version
-v
Print the program version number and exit.
file
Execute commands from file.

Built-in Variable: argv
The command line arguments passed to Octave are available in this variable. For example, if you invoked Octave using the command

octave --no-line-editing --silent

argv would be a string vector with the elements --no-line-editing and --silent.

Built-in Variable: nargin
At the top level, this variable is defined as the number of command line arguments that were passed to Octave.

Built-in Variable: program_invocation_name
Built-in Variable: program_name
When Octave starts, the value of the built-in variable program_invocation_name is automatically set to the name that was typed at the shell prompt to run Octave, and the value of program_name is automatically set to the final component of program_invocation_name. For example, if you typed `/usr/local/bin/octave' to start Octave, program_invocation_name would have the value `/usr/local/bin/octave', and program_name would have the value octave.

If executing a script from the command line (e.g., octave foo.m or using an executable Octave script, the program name is set to the name of the script. See section Executable Octave Programs for an example of how to create an executable Octave script.

Here is an example of using these variables to reproduce Octave's command line.

printf ("%s", program_name);
for i = 1:nargin
  printf (" %s", i, argv(i,:));
endfor
printf ("\n");

See section Index Expressions for an explanation of how to properly index arrays of strings and substrings in Octave.

Startup Files

When Octave starts, it looks for commands to execute from the following files:

OCTAVE_HOME/share/octave/site/m/startup/octaverc
Where OCTAVE_HOME is the directory in which all of Octave is installed (the default is `/usr/local'). This file is provided so that changes to the default Octave environment can be made globally for all users at your site for all versions of Octave you have installed. Some care should be taken when making changes to this file, since all users of Octave at your site will be affected.
OCTAVE_HOME/share/octave/VERSION/m/startup/octaverc
Where OCTAVE_HOME is the directory in which all of Octave is installed (the default is `/usr/local'), and VERSION is the version number of Octave. This file is provided so that changes to the default Octave environment can be made globally for all users for a particular version of Octave. Some care should be taken when making changes to this file, since all users of Octave at your site will be affected.
~/.octaverc
This file is normally used to make personal changes to the default Octave environment.
.octaverc
This file can be used to make changes to the default Octave environment for a particular project. Octave searches for this file in the current directory after it reads `~/.octaverc'. Any use of the cd command in the `~/.octaverc' file will affect the directory that Octave searches for the file `.octaverc'. If you start Octave in your home directory, commands from from the file `~/.octaverc' will only be executed once.

A message will be displayed as each of the startup files is read if you invoke Octave with the --verbose option but without the --silent option.

Startup files may contain any valid Octave commands, including multiple function definitions.


Go to the first, previous, next, last section, table of contents.