Matlab external scripts can not escape shell

3 views (last 30 days)
Hi! I am trying to call a script or executing a command via system in bash. However, it seems Matlab does not let the command escape it's shell session(?)?
What I am trying to do is running something like
xelatex --shell-escape main.tex
since I have multiple tikz-figures to be compiled. However latex stucks and complains that shell escape was not working. running the exact same command in Terminal works (I made sure to provide the path to xelatex). I also tried to provide a shell script, with this command, hoping that would change something, but it doesn't.
#!/bin/bash
/Library/TeX/texbin/xelatex --shell-escape main.tex
This script works when executed via terminal, but not using system(...) or !... Do you have any idea how to get this done? Or is this a inherent restriction?
  2 Comments
Lucas-Raphael Müller
Lucas-Raphael Müller on 28 Sep 2017
Hm, I thought posting latex errors here was not useful, but here you go:
if ispc
executeLatex = 'xelatex --shell-escape main.tex';
elseif isunix
executeLatex = '/Library/TeX/texbin/xelatex --shell-escape main.tex';
end
response = system(executeLatex);
This is the output
This is XeTeX, Version 3.14159265-2.6-0.99992 (TeX Live 2015) (preloaded format=xelatex)
\write18 enabled.
entering extended mode
(./main.tex
LaTeX2e <2016/03/31>
Babel <3.9q> and hyphenation patterns for 81 language(s) loaded.
(/usr/local/texlive/2015/texmf-dist/tex/latex/koma-script/scrartcl.cls
Document Class: scrartcl 2015/10/03 v3.19a KOMA-Script document class (article)
...
(./data/patientInformation.tex) (./main.toc) [1]
(./data/uncertaintyParameters.tex) [2] (./data/isoSlicePlane1_nominal.tex
! Package tikz Warning: The key 'up to date check=md5' is impossible, there is
no macro to compute MD5. Falling back to 'up to date check=diff'.
===== 'mode=convert with system call': Invoking 'xelatex -shell-escape -halt-on
-error -interaction=batchmode -jobname "data/figures/main-figure0" "\def\tikzex
ternalrealjob{main}\input{main}"' ========
sh: xelatex: command not found
! Package tikz Error: Sorry, the system call 'xelatex -shell-escape -halt-on-er
ror -interaction=batchmode -jobname "data/figures/main-figure0" "\def\tikzexter
nalrealjob{main}\input{main}"' did NOT result in a usable output file 'data/fig
ures/main-figure0' (expected one of .pdf:.jpg:.jpeg:.png:.bmp:). Please verify
that you have enabled system calls. For pdflatex, this is 'pdflatex -shell-esca
pe'. Sometimes it is also named 'write 18' or something like that. Or maybe the
command simply failed? Error messages can be found in 'data/figures/main-figur
e0.log'. If you continue now, I'll try to typeset the picture.
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.1121 \end{tikzpicture}
%
?
As I said compiling in terminal with same command works fine.

Sign in to comment.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by