Running Octave |
This document tells you how to start and exit Octave. You will also learn
how to write your own executable Octave programs.
|
If you get into trouble, you can usually interrupt Octave by typing Control-C (usually written C-c for short). C-c gets its name from the fact that you type it by holding down the CTRL key and then pressing c. Doing this will normally return you to Octave's prompt.
To exit Octave, type quit, exit or Control-D at the Octave prompt. On systems that support job control, you can suspend Octave by sending it a SIGTSTP signal, usually by typing C-z.
Once you have learned Octave, you may want to write self-contained Octave scripts, using the #! script mechanism. You can do this on GNU systems and on many Unix systems (The #! mechanism works on Unix systems derived from Berkeley Unix, System V Release 4, and some System V Release 3 systems. On OS/2 you must replace #! by extproc). For example, you could create a text file named hello.cmd, containing the following lines:
extproc octave -qf # a sample Octave program printf ("Hello, world!\n");
After making this file executable (with the chmod command, if necessary), you can simply type:
hello
at the shell, and the system will arrange to run Octave as if you had typed:
octave -qf hello.cmd
The line beginning with extproc lists the full file name of an interpreter to be run, and an optional initial command line argument to pass to that interpreter. The operating system then runs the interpreter with the given argument and the full argument list of the executed program. The first argument in the list is the full file name of the Octave program. The rest of the argument list will either be options to Octave, or data files, or both. The -qf option is usually specified in stand-alone Octave programs to prevent them from printing the normal startup message, and to keep them from behaving differently depending on the contents of a particular user's ~/.octaverc file. Self-contained Octave scripts are useful when you want to write a program which users can invoke without knowing that the program is written in the Octave language.