Passing a path that contains spaces and parentheses to MATLAB from the terminal/bash -
i writing script have phone call matlab terminal , pass path argument contains lousy characters.
as expected, running problem when path contains spaces / parentheses. here minimal illustration illustrate issue:
matlabcmd="/applications/matlab_r2014b.app/bin/matlab -nodesktop -nosplash" run_dir="users/me/my directory spaces (and parentheses)/" $matlabcmd -r "addpath('${run_dir}'),exit"
some things have tried:
different combinations of double-quotes , single-quotes in commands above (this fails @ calling matlab).
using escape character run_dir="users/me/my directory\ with\ spaces\ \(and parentheses\)/"
(this manages phone call matlab, matlab gets confused spaces... , addpath
not work).
is there hope?
try
matlabcmd="/applications/matlab_r2014b.app/bin/matlab -nodesktop -nosplash" run_dir="users/me/my directory spaces (and parentheses)/" $matlabcmd -r "addpath(getenv('run_dir')),exit"
this prevent quoting/escaping nightmare , should lead desired effect.
bash matlab
No comments:
Post a Comment