'How to run octave script from shell at launch

I'm using Ubuntu system. To run MATLAB script at launch, I can type matlab -nodesktop -r "run ./my_program.m".

How can I achieve the same function on Octave, like octave --no-gui -some_command?

I've read this post and this post. They did not answer my question.



Solution 1:[1]

Currently looks like it is enough to say for script (not plain function)

octave my_program.m

Also if you have octave installed in your path you could and in the beginning of script as the first line the desired interpreter (works for python, bash, whatever), for example for default location :

#!/usr/bin/octave

and you can run them without even adding the octave in front... just the script name....

Solution 2:[2]

For Windows users:

I see it's a bit harder, since there's no "octave.exe" file.

I do have: "C:\Program Files\GNU Octave\Octave-6.4.0\mingw64\bin\octave-cli-6.4.0.exe" which works after adding both parent directories "C:\Program Files\GNU Octave\Octave-6.4.0\mingw64\bin" and "C:\Program Files\GNU Octave\Octave-6.4.0\mingw64" to PATH.

All this happens automatically in the startup script which is the normal entry point of the SW:

"C:\Program Files\GNU Octave\Octave-6.4.0\octave.vbs"

Finaly, after adding all to path I run it like this:

"C:\Program Files\GNU Octave\Octave-6.4.0\mingw64\bin\octave-cli-6.4.0.exe" "C:\MatlabScripts\matlabScript1.m" c:\temp\myCuteImage [example for prm]

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sami Varjo
Solution 2 ephraim