1

Shell escape not enabled, is a frequent issue especially when combined with components that are not native to a tex distro path such as Gnuplot in MiKTeX.

For my sins, I run dozens of editor configurations across multiple distros and frequently switch compilation settings, thus need a fairly uniform way to simply check what is or is not active.

I am unclear as to how much each TeX / OS platform variant can internally feed back with reliable file locations when target files are missing. As an example, when calling \addplot3[contour gnuplot on windows I can run the following MWE, but think it could be better done or expanded for broader use by variables, such as a package name. Can any one point me towards good diagnostic routines, possibly platform independent?

\documentclass[border=10pt]{standalone}
\RequirePackage{ifplatform}
\usepackage{ifpdf}
%% First sanity test if pdfLaTeX is active
\ifpdf
  \errmessage{OK ! pdfLaTeX IS active PRESS ENTER TO CONTINUE}
\else
  \errmessage{plain latex and dvipdf ? PLEASE SWITCH to pdfLaTeX}
\fi
%% Second sanity test if shell escape is available
\ifshellescape
    \errmessage{OK   Shell-Escape IS active  PRESS ENTER TO CONTINUE}
\else
    \errmessage{Shell-Escape is NOT working. PLEASE ADD --shell-escape to pdfLaTeX arguments}
\fi
\begin{document}
%% if shell escape is working we can get console feedback
\def\tmpfile{w18-active-\the\year\the\month\the\day\the\time.cmd}
\immediate\write18{echo echo Shell-Escape is active > "\tmpfile"}
\ifpdf
  \immediate\write18{echo echo You are using pdflatex >> "\tmpfile"}
\else
  \immediate\write18{echo echo plain latex and dvipdf ? switch to pdflatex >> "\tmpfile"}
\fi
% Check where gnuplot is Fist check if we can get version info feedback
\immediate\write18{echo gnuplot -e  'show version long' >> "\tmpfile"}
\immediate\write18{echo echo If you do not see version above then add any of the following locations to your path >> "\tmpfile"}
% these lines are under review as it should traverse editor roots, but for present we check relative to root and system path
\immediate\write18{echo where /r \ gnuplot.exe >> "\tmpfile"}
\immediate\write18{echo where gnuplot.exe >> "\tmpfile"}

\immediate\write18{echo set path >> "\tmpfile"}
% Store latest results WILL be overwritten on each run
\immediate\write18{"\tmpfile" >results.txt}
% Add a pause in case user wants to manually edit / run cmd file
\immediate\write18{echo pause>> "\tmpfile"}
\immediate\write18{"\tmpfile"}
\immediate\write18{del "\tmpfile"}
ALL DONE SEE CONSOLE OUTPUT OR Results.txt
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.