Octave shows gnuplot in interactive mode but not from command line - octave

I'm writing a script in the octave programming language that calls plot. When I open the octave console in interactive mode and paste the script in, gnuplot appears correctly. However, when I run the script from a command line via
octave ./myscript.m
all printf work, but no gnuplot window appears. This happens with as simple a script as
plot([0 1; 2 3])
Any ideas why this might be happening?
Thanks.

Try running the script with the --persist flag. This flag tells Octave to "go to interactive mode after
--eval or reading from a file named on the command line."
> octave --persist ./myscript.m

Related

Unable to display Octave figure in Atom on MacOS

I tried few different terminal implementations such as terminal-plus or platformio-ide-terminal on Atom (1.38.2) to run some Octave exercises. I noticed that the Octave shell runs normally until I try to plot anything.
When I type figure into the shell no window pops up and no error or any other messages appear in the terminal. Yet everything runs OK in Mac (Mojave 10.14.5) own terminal
Figured it out. The popup is there but it is buried under Atom itself. If I call figure(gcf) instead of simply figure it brings the window to the foreground and displays above the IDE. If anyone has a better answer I'll be happy to accept

octave opens GUI when I type "octave" in terminal

I have a problem:
installed octave and do not know why, every time I type octave in the terminal opens the GUI interface (gui --force-octave) Octave and not the terminal octave as is right. how can I fix this?
If you have Octave 4.0, the GUI is the default:
** A graphical user interface is now the default when running Octave interactively. The start-up option --no-gui will run the familiar command line interface...
https://www.gnu.org/software/octave/NEWS-4.0.html
You can add this alias octave='octave --no-gui' to your ~/.bashrc file and every time you type octave, it opens in your terminal.
Good luck

MonoDevelop's debugger and xterm/gnome-terminal

I am using Xubuntu 15.04. I tried to run a basic console app using MonoDevelop, the latest one. I did a new project and this appears when I try to debug it:
Could not connect to the debugger
I googled for answers and I found out that there is a problem with the gnome-terminal, that it no longer accepts the --disable-factory argument and something about unchecking the "Run on external console". I unchecked that and when I press to run, it closed it immediately.
Try executing MonoDevelop as sudo
$ sudo monodevelop
It takes Xterm as output terminal emulator.
EDIT
Run Monodevelop as root can be a BIG mistake.
Best way is to write an script that unsets GNOME desktop session and run monodevelop, as Oskar says.
Try this one (copy and paste it on vim/nano and save as monodevelop.sh)
#!/bin/bash
unset GNOME_DESKTOP_SESSION_ID
monodevelop
Put it on your home (for example) and give it execution permissions:
chmod +x ./monodevelop.sh
When you want to run it, execute ./monodevelop.sh. Or you can add it as GNOME shell application following this guide.

How do I stop octave plots hanging with line editing turned off?

I'm using Debian Jessie and GNU Octave, version 3.8.1
If I run octave with the --no-line-editing switch on, to avoid using readline
$ octave --no-line-editing
and execute this command,
>> t=0:1; plot(t);
then the plot window hangs. Without the line editing switch it's ok.
Does anyone know how to work around this, or how to report the bug?
This has already been reported as Debian Bug #675509 and Octave bug #37795 so you don't to report this bug again.
You can use gnuplot: just execute graphics_toolkit gnuplot before any plotting or add it to your .octaverc to get it eexecuted everytime you start octave.

Beginning Lua: How to call functions from terminal on Mac OS?

I'm new to Lua and work around with some tutorials, try some basic stuff like coding common algorithms etc.
But I have some trouble while using the lua interpreter on my mac os machine.
For example let's say we have a file called 'sample.lua', holds the code line:
function fib(n) return n<2 and n or fib(n-1)+fib(n-2) end
How do I run that function from terminal?
If I don't use any function, I just call the script with 'lua script.lua' - works!
Next question points on the basic understanding between the usage of non-compiled and compiled lua-source. Why is lua code run without compiling, like I mentioned before (lua script.lua)? Or will this statement compile the code temporarily and run afterwards?
Thanks in advance
chris
You can run lua from the terminal with the -i flag:
lua -i luascript.lua
This will execute the script and then put the interpreter into interactive mode. Then you could call the function right from the interactive prompt:
fib(3)
To run that function from the terminal, you would have to do something like:
lua -e"dofile'sample.lua' print(fib(3))"
The -e there just tells it to execute the following string, which loads your file 'sample.lua' and then prints the result of fib(3) to stdout.
I don't know the answer to your second question though.
Lua scripts are always compiled into Lua VM instructions before running. Precompiled scripts just skip this step.