# Enabling “--shell-escape” on TeXworks under MiKTeX

After resolving the problem on my previous question, I applied to finally install Gnuplot 4.6; and after a successful installation I had to allow the --shell-escape option on TeXworks, so I added a new Typesetting Tool on the Preferences menu, called pdfLaTeX+ShellEscape.

The lines of code inserted into the tool configuration are listed below:

$synctexoption -undump=pdflatex --shell-escape$fullname


The problem is that when I try to compile my MWE (MYname.tex) with the above specified option:

\documentclass{article}
\usepackage{pgfplots}
%
\begin{document}
\begin{tikzpicture}
%
\begin{axis}[no markers,samples=30]
\end{axis}
%
\end{tikzpicture}
%
\end{document}


I get this messge:

! Package pgfplots Error: Sorry, the gnuplot-result file 'MYname.pgf-plot.table'
could not be found. Maybe you need to enable the shell-escape feature? For
pdflatex, this is '>> pdflatex -shell-escape'. You can also invoke
'>> gnuplot <file>.gnuplot' manually on the respective gnuplot file..

See the pgfplots package documentation for explanation.
Type  H <return>  for immediate help.
...

?


I am running TeXworks 0.44, and until now it didn't show this kind of stubbornness because I compiled every document without problems.

I did also some research and I found that I could write -enable-write18 but even after this try I get the same errmsg and so I'm stuck again with the plots problem (although I discovered a powerful program like Gnuplot I don't know how to set LaTeX properly).

P.S. : Sorry for the deleted question with the same title, that issue was created by a simple human error.

-
Check the folder to see if there is a .gnu file with the name of the .tex file. It may be even a .dot something else but it wont be aux, log, and the standard LaTeX ones. – dustin Aug 2 '13 at 15:25
I found the file MYname.pgf-plot.gnuplot on the same folder, in addition to the classic aux and log files, but at this point I don't know what to do. – Andrea L. Aug 2 '13 at 15:29
What happened was gnu didn't process the file. If you process this file now, you will have the .table or it may name it a .tex file and then all will work. This happens sometimes with shell escape enabled. It has to do with something you havent set in TeXworks I presume. – dustin Aug 2 '13 at 15:33
I'm sure it will look like that I don't deserve my rep. points, but I have to aks this question: by processing this single file do I have to open it with gnuplot program? If so I already tried this but I got the same error. – Andrea L. Aug 2 '13 at 15:36
What I've done is: go to the file MYname.pgf-plot.gnuplot, r-click and select wgnuplot program to open the specific extension, after that the MYname.pgf-plot.table was created and it all worked like a charm. Now the only question is if I've set the Typesetting tool correctly, because I don't know if I've done some mistake – Andrea L. Aug 2 '13 at 15:44

Since we were able to establish that the compilation generated a .pgf-plot.gnuplot file, the problem was that this file was not compiled in gnuplot.
1. run gnuplot on the .pgf-plot.gnuplot file to create a .table or .tex file and then compile again.
2. we can modify the calling of --shell-escape for TeXworks to --tex-option=--shell-escape and then compile again without running gnuplot this time.
3. another option posed by texenthusiast is to use a program such as Latexmk to compile multiple times; however, I still believe we would need options two's modification of --shell-escape which was discussed on TUG's message board here https://www.tug.org/pipermail/texworks/2011q2/004166.html
Also Make sure the system wide path for gnuplot is set properly depending on Linux or Windows – texenthusiast Aug 2 '13 at 16:50