Passing arguments to octave function from within bash script

Viewed 12619

I wrote a function in Octave that takes in a line read from a file (one line at a time) as input argument. I use a bash script to read a line at a time from the file and then pass that as argument to the octave function from within the script.

My bash script looks like so:

#!/bin/bash  

while read line
do
  octave --silent --eval 'myOctaveFunc("${line}")'
done < "inFileName"

When I execute above script, octave throws errors like:

error: called from:
error:   /usr/share/octave/3.2.3/m/miscellaneous/fullfile.m at line 43, column 11
error: evaluating argument list element number 2
error: evaluating argument list element number 1
error:   /usr/libexec/octave/packages/gsl-1.0.8/i386-redhat-linux-gnu-api-v37/PKG_ADD at line 47, column 1
error: addpath: expecting all args to be character strings
error: addpath: expecting all args to be character strings
error: addpath: expecting all args to be character strings
error: addpath: expecting all args to be character strings

and so on..

I have been able to run the octave script myOctaveFunc.m with input arguments such as helloWorld from the command line. The problem arises when I try to run it from within the bash script.

My questions are:
1. How do I get the octave function running from within the bash script?
2. I am using gvim to edit the bash script. When I type in the line to invoke the octave script, I see that the ${line} is colored differently as compared to normal circumstances. Is that because of the '' used to invoke the octave function? If so, should I be worried about it?

1 Answers
Related