Show Octave plot from shell script

1

If I invoke Octave to plot something, it needs the interactive prompt to stay running and show the plot.

When running from the command line, the --persist option will force Octave to keep open after all Octave commands are executed, so I can see and manipulate the plot.

--persist Go interactive after --eval or reading from FILE.

However, when I invoke Octave from a non-interactive shell script, it cannot enter interactive mode, does not react to --persist command line option, nor the pause() command inside Octave scripts.

Is there any way to allow Octave invisibly stay interactive, if invoked from a shell script?

dronus

Posted 2015-05-19T19:12:58.667

Reputation: 1 482

Answers

2

I try to reproduce your problem but it was not possible. I did this test files oct.txt

x = -10:.1:10;
y = sin(x).*exp(-abs(x));
plot(x,y)

and go.sh (and I make it executable with chmod u+x go.sh)

#!/bin/bash
octave -q --persist oct.txt  # It calls the octave and remain as interactive
echo " Now we continue "     # Here the script continue when you exit from octave
sleep 5                      # Do some stuffs
exit                         # It exits

When I run it with ./go.sh it starts octave and when I exit it continues with the script.


When I add pause() or pause(10) to the bottom of oct.txt and I call octave with the command octave -q oct.txt & it behaves as supposed:

  1. the script starts octave in background and continues
  2. eventually the script ends leaving alive the octave windows

Unfortunately the windows of octave is frozen from the pause command and not so useful.


  • GNU bash, version 4.3.11
  • GNU Octave, version 3.8.1

Hastur

Posted 2015-05-19T19:12:58.667

Reputation: 15 043

Same here, Hastur's example works exatly as he says. +1 for me. – MariusMatutiae – 2015-06-24T16:57:53.580

Ah I forgot to mention the scripts where non-interactive. Added that. I'm sorry! – dronus – 2015-06-24T22:19:50.487