After check out source code of `ob-octave.el`, I found only one places used `ans.m`:

```

(defvar org-babel-octave-wrapper-method
  "%s
if ischar(ans), fid = fopen('%s', 'w'); fprintf(fid, '%%s\\n', ans); fclose(fid);
else, dlmwrite('%s', ans, '\\t')
end")

```

Might Octave package versions compatition issue or something else raised this error. Based on the error hints, should  be the calling to `ans` is wrong. After tesing upper code in Octave REPL, it works fine. that weird. The upper variable is just a wrapper around src block `body` for saving `ans` to file.

Anyway, hope somebody who knows elisp and Octave can check this out.


On 03/23/2018 08:09 AM, Eric S Fraga wrote:
On Friday, 23 Mar 2018 at 07:55, stardiviner wrote:
I got the following error after executing src block:

```

error: invalid call to script /usr/share/octave/4.2.2/m/help/ans.m
I see the same.  Not sure why this is happening but you can fix it but
adding any line after the saveas statement that would generate a value,
e.g. just a "1" will do:

#+begin_src org
  ,#+begin_src octave :results file :dir "data/images" :file "figure1.png"
  clf ();
  surf (peaks);
  saveas (1, "figure1.png");
  1
  ,#+end_src
#+end_src