<html lang="en"> <head> <title>Command Line Options - GNU Octave</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="GNU Octave"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Invoking-Octave-from-the-Command-Line.html#Invoking-Octave-from-the-Command-Line" title="Invoking Octave from the Command Line"> <link rel="next" href="Startup-Files.html#Startup-Files" title="Startup Files"> <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> <meta http-equiv="Content-Style-Type" content="text/css"> <style type="text/css"><!-- pre.display { font-family:inherit } pre.format { font-family:inherit } pre.smalldisplay { font-family:inherit; font-size:smaller } pre.smallformat { font-family:inherit; font-size:smaller } pre.smallexample { font-size:smaller } pre.smalllisp { font-size:smaller } span.sc { font-variant:small-caps } span.roman { font-family:serif; font-weight:normal; } span.sansserif { font-family:sans-serif; font-weight:normal; } --></style> </head> <body> <div class="node"> <a name="Command-Line-Options"></a> <p> Next: <a rel="next" accesskey="n" href="Startup-Files.html#Startup-Files">Startup Files</a>, Up: <a rel="up" accesskey="u" href="Invoking-Octave-from-the-Command-Line.html#Invoking-Octave-from-the-Command-Line">Invoking Octave from the Command Line</a> <hr> </div> <h4 class="subsection">2.1.1 Command Line Options</h4> <p><a name="index-Octave-command-options-29"></a><a name="index-command-options-30"></a><a name="index-options_002c-Octave-command-31"></a> Here is a complete list of the command line options that Octave accepts. <dl> <dt><code>--debug</code><dt><code>-d</code><dd><a name="index-g_t_0040code_007b_002d_002ddebug_007d-32"></a><a name="index-g_t_0040code_007b_002dd_007d-33"></a>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. <br><dt><code>--doc-cache-file </code><var>filename</var><dd><a name="index-g_t_0040code_007b_002d_002ddoc_002dcache_002dfile-_0040var_007bfilename_007d_007d-34"></a>Specify the name of the doc cache file to use. The value of <var>filename</var> specified on the command line will override any value of <samp><span class="env">OCTAVE_DOC_CACHE_FILE</span></samp><!-- /@w --> found in the environment, but not any commands in the system or user startup files that use the <code>doc_cache_file</code> function. <br><dt><code>--echo-commands</code><dt><code>-x</code><dd><a name="index-g_t_0040code_007b_002d_002decho_002dcommands_007d-35"></a><a name="index-g_t_0040code_007b_002dx_007d-36"></a>Echo commands as they are executed. <br><dt><code>--eval </code><var>code</var><dd>Evaluate <var>code</var> and exit when finished unless <samp><span class="option">--persist</span></samp> is also specified. <br><dt><code>--exec-path </code><var>path</var><dd><a name="index-g_t_0040code_007b_002d_002dexec_002dpath-_0040var_007bpath_007d_007d-37"></a>Specify the path to search for programs to run. The value of <var>path</var> specified on the command line will override any value of <samp><span class="env">OCTAVE_EXEC_PATH</span></samp><!-- /@w --> found in the environment, but not any commands in the system or user startup files that set the built-in variable <samp><span class="env">EXEC_PATH</span></samp><!-- /@w -->. <br><dt><code>--help</code><dt><code>-h</code><dt><code>-?</code><dd><a name="index-g_t_0040code_007b_002d_002dhelp_007d-38"></a><a name="index-g_t_0040code_007b_002dh_007d-39"></a><a name="index-g_t_0040code_007b_002d_003f_007d-40"></a>Print short help message and exit. <br><dt><code>--image-path </code><var>path</var><dd><a name="index-g_t_0040code_007b_002d_002dimage_002dpath-_0040var_007bpath_007d_007d-41"></a>Add path to the head of the search path for images. The value of <var>path</var> specified on the command line will override any value of <samp><span class="env">OCTAVE_IMAGE_PATH</span></samp><!-- /@w --> found in the environment, but not any commands in the system or user startup files that set the built-in variable <samp><span class="env">IMAGE_PATH</span></samp><!-- /@w -->. <br><dt><code>--info-file </code><var>filename</var><dd><a name="index-g_t_0040code_007b_002d_002dinfo_002dfile-_0040var_007bfilename_007d_007d-42"></a>Specify the name of the info file to use. The value of <var>filename</var> specified on the command line will override any value of <samp><span class="env">OCTAVE_INFO_FILE</span></samp><!-- /@w --> found in the environment, but not any commands in the system or user startup files that use the <code>info_file</code> function. <br><dt><code>--info-program </code><var>program</var><dd><a name="index-g_t_0040code_007b_002d_002dinfo_002dprogram-_0040var_007bprogram_007d_007d-43"></a>Specify the name of the info program to use. The value of <var>program</var> specified on the command line will override any value of <samp><span class="env">OCTAVE_INFO_PROGRAM</span></samp><!-- /@w --> found in the environment, but not any commands in the system or user startup files that use the <code>info_program</code> function. <br><dt><code>--interactive</code><dt><code>-i</code><dd><a name="index-g_t_0040code_007b_002d_002dinteractive_007d-44"></a><a name="index-g_t_0040code_007b_002di_007d-45"></a>Force interactive behavior. This can be useful for running Octave via a remote shell command or inside an Emacs shell buffer. For another way to run Octave within Emacs, see <a href="Emacs-Octave-Support.html#Emacs-Octave-Support">Emacs Octave Support</a>. <br><dt><code>--line-editing</code><dd><a name="index-g_t_0040code_007b_002d_002dline_002dediting_007d-46"></a>Force readline use for command-line editing. <br><dt><code>--no-history</code><dt><code>-H</code><dd><a name="index-g_t_0040code_007b_002d_002dno_002dhistory_007d-47"></a><a name="index-g_t_0040code_007b_002dH_007d-48"></a>Disable recording of command-line history. <br><dt><code>--no-init-file</code><dd><a name="index-g_t_0040code_007b_002d_002dno_002dinit_002dfile_007d-49"></a>Don't read the initialization files <samp><span class="file">~/.octaverc</span></samp> and <samp><span class="file">.octaverc</span></samp>. <br><dt><code>--no-init-path</code><dd><a name="index-g_t_0040code_007b_002d_002dno_002dinit_002dpath_007d-50"></a>Don't initialize the search path for function files to include default locations. <br><dt><code>--no-line-editing</code><dd><a name="index-g_t_0040code_007b_002d_002dno_002dline_002dediting_007d-51"></a>Disable command-line editing. <br><dt><code>--no-site-file</code><dd><a name="index-g_t_0040code_007b_002d_002dno_002dsite_002dfile_007d-52"></a>Don't read the site-wide <samp><span class="file">octaverc</span></samp> initialization files. <br><dt><code>--norc</code><dt><code>-f</code><dd><a name="index-g_t_0040code_007b_002d_002dnorc_007d-53"></a><a name="index-g_t_0040code_007b_002df_007d-54"></a>Don't read any of the system or user initialization files at startup. This is equivalent to using both of the options <samp><span class="option">--no-init-file</span></samp> and <samp><span class="option">--no-site-file</span></samp>. <br><dt><code>--path </code><var>path</var><dt><code>-p </code><var>path</var><dd><a name="index-g_t_0040code_007b_002d_002dpath-_0040var_007bpath_007d_007d-55"></a><a name="index-g_t_0040code_007b_002dp-_0040var_007bpath_007d_007d-56"></a>Add path to the head of the search path for function files. The value of <var>path</var> specified on the command line will override any value of <samp><span class="env">OCTAVE_PATH</span></samp><!-- /@w --> found in the environment, but not any commands in the system or user startup files that set the internal load path through one of the path functions. <br><dt><code>--persist</code><dd><a name="index-g_t_0040code_007b_002d_002dpersist_007d-57"></a>Go to interactive mode after <samp><span class="option">--eval</span></samp> or reading from a file named on the command line. <br><dt><code>--silent</code><dt><code>--quiet</code><dt><code>-q</code><dd><a name="index-g_t_0040code_007b_002d_002dsilent_007d-58"></a><a name="index-g_t_0040code_007b_002d_002dquiet_007d-59"></a><a name="index-g_t_0040code_007b_002dq_007d-60"></a>Don't print the usual greeting and version message at startup. <br><dt><code>--traditional</code><dt><code>--braindead</code><dd><a name="index-g_t_0040code_007b_002d_002dtraditional_007d-61"></a><a name="index-g_t_0040code_007b_002d_002dbraindead_007d-62"></a>For compatibility with <span class="sc">matlab</span>, set initial values for user preferences to the following values <pre class="example"> PS1 = ">> " PS2 = "" allow_noninteger_range_as_index = true beep_on_error = true confirm_recursive_rmdir = false crash_dumps_octave_core = false default_save_options = "-mat-binary" do_braindead_shortcircuit_evaluation = true fixed_point_format = true history_timestamp_format_string = "%%-- %D %I:%M %p --%%" page_screen_output = false print_empty_dimensions = false </pre> <p class="noindent">and disable the following warnings <pre class="example"> Octave:abbreviated-property-match Octave:fopen-file-in-path Octave:function-name-clash Octave:load-file-in-path </pre> <br><dt><code>--verbose</code><dt><code>-V</code><dd><a name="index-g_t_0040code_007b_002d_002dverbose_007d-63"></a><a name="index-g_t_0040code_007b_002dV_007d-64"></a>Turn on verbose output. <br><dt><code>--version</code><dt><code>-v</code><dd><a name="index-g_t_0040code_007b_002d_002dversion_007d-65"></a><a name="index-g_t_0040code_007b_002dv_007d-66"></a>Print the program version number and exit. <br><dt><var>file</var><dd>Execute commands from <var>file</var>. Exit when done unless <samp><span class="option">--persist</span></samp> is also specified. </dl> <p>Octave also includes several functions which return information about the command line, including the number of arguments and all of the options. <!-- argv src/octave.cc --> <p><a name="doc_002dargv"></a> <div class="defun"> — Built-in Function: <b>argv</b> ()<var><a name="index-argv-67"></a></var><br> <blockquote><p>Return the command line arguments passed to Octave. For example, if you invoked Octave using the command <pre class="example"> octave --no-line-editing --silent </pre> <p class="noindent"><code>argv</code> would return a cell array of strings with the elements <samp><span class="option">--no-line-editing</span></samp> and <samp><span class="option">--silent</span></samp>. <p>If you write an executable Octave script, <code>argv</code> will return the list of arguments passed to the script. See <a href="Executable-Octave-Programs.html#Executable-Octave-Programs">Executable Octave Programs</a>, for an example of how to create an executable Octave script. </p></blockquote></div> <!-- program_name src/octave.cc --> <p><a name="doc_002dprogram_005fname"></a> <div class="defun"> — Built-in Function: <b>program_name</b> ()<var><a name="index-program_005fname-68"></a></var><br> <blockquote><p>Return the last component of the value returned by <code>program_invocation_name</code>. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dprogram_005finvocation_005fname.html#doc_002dprogram_005finvocation_005fname">program_invocation_name</a>. </p></blockquote></div> <!-- program_invocation_name src/octave.cc --> <p><a name="doc_002dprogram_005finvocation_005fname"></a> <div class="defun"> — Built-in Function: <b>program_invocation_name</b> ()<var><a name="index-program_005finvocation_005fname-69"></a></var><br> <blockquote><p>Return the name that was typed at the shell prompt to run Octave. <p>If executing a script from the command line (e.g., <code>octave foo.m</code>) or using an executable Octave script, the program name is set to the name of the script. See <a href="Executable-Octave-Programs.html#Executable-Octave-Programs">Executable Octave Programs</a>, for an example of how to create an executable Octave script. <!-- Texinfo @sp should work but in practice produces ugly results for HTML. --> <!-- A simple blank line produces the correct behavior. --> <!-- @sp 1 --> <p class="noindent"><strong>See also:</strong> <a href="doc_002dprogram_005fname.html#doc_002dprogram_005fname">program_name</a>. </p></blockquote></div> <p>Here is an example of using these functions to reproduce the command line which invoked Octave. <pre class="example"> printf ("%s", program_name ()); arg_list = argv (); for i = 1:nargin printf (" %s", arg_list{i}); endfor printf ("\n"); </pre> <p class="noindent">See <a href="Indexing-Cell-Arrays.html#Indexing-Cell-Arrays">Indexing Cell Arrays</a>, for an explanation of how to retrieve objects from cell arrays, and <a href="Defining-Functions.html#Defining-Functions">Defining Functions</a>, for information about the variable <code>nargin</code>. </body></html>