Difference between revisions of "Write18"

From Wiki
Jump to navigation Jump to search
(How to check for write18)
m (Text replacement - "</cmd>" to "}}")
 
(13 intermediate revisions by 7 users not shown)
Line 4: Line 4:
 
=== Windows - MikTeX ===
 
=== Windows - MikTeX ===
  
'''MikTeX 2.4'''
+
'''MikTeX 2.5/2.6'''
  
Create a file <code>[localtexmf PATH]\miktex\config\miktex.ini</code> and add the following line to it:
+
Each application now has its own configuration file. To enable <code>write18</code> run
write18=enable
+
initexmf --edit-config-file=miktex\config\pdftex.ini
''(Because of some unknown reason, <code>write18=enable</code> in <code>[localtexmf PATH]\miktex\config\miktex.ini</code> may be ignored on some computers. In that case make the change in <code>[MikTeX PATH]\miktex\config\miktex.ini</code>, but you may have to repeat this step every time you update MikTeX packages.)''
+
or (if you have MikTeX 2.5 or a version of ConTeXt from 2006)
 
 
'''MikTeX 2.5'''
 
 
 
Each application now has it's own configuration file. To enable <code>write18</code> run
 
 
  initexmf --edit-config-file=miktex\config\pdfetex.ini
 
  initexmf --edit-config-file=miktex\config\pdfetex.ini
 
and put
 
and put
 
  EnableWrite18=t
 
  EnableWrite18=t
into it. An alternative is to se the environment variable <code>MIKTEX_ENABLEWRITE18=t</code>.
+
into it. An alternative is to set the environment variable <code>MIKTEX_ENABLEWRITE18=t</code>.
 +
 
 +
=== Windows/Linux/Mac - TexLive ===
 +
 
 +
'''TexLive 2008'''
  
 +
Open the file 'path to TexLive'/texmf/web2c/texmf.cnf and search in the file for the following passage:
 +
% Enable system commands via \write18{...}?  Obviously insecure, despite
 +
% being so useful.
 +
shell_escape = f
 +
change here the option from false to true so that the last line above looks like
 +
shell_escape = t
 +
After that you just have to recompile your formats. That is done by
 +
texexec --make --all
 +
or/and
 +
texexec --make --all cont-xx
 +
where xx stands for your needed countrycode.
 +
Additionally if you're using MK IV already you have to do the following steps afterwards to get a running environment:
 +
luatools --generate
 +
context --make --all
 +
context --make --all cont-xx
 +
after that write18 sould be enabled and you sould be able to use it.
  
 
=== Linux/Mac ===
 
=== Linux/Mac ===
Line 25: Line 41:
 
will should return you something like
 
will should return you something like
 
  /usr/local/teTeX/texmf.cnf
 
  /usr/local/teTeX/texmf.cnf
 +
or
 +
/usr/local/gwTeX/texmf.cnf
  
 
In that file you'll probably find a line reading
 
In that file you'll probably find a line reading
Line 32: Line 50:
  
 
== How to check if write18 is turned on ==
 
== How to check if write18 is turned on ==
Sometimes while writings a module, one needs to check if write18 is enabled or now. There are different ways in which this can be done.
+
Sometimes while writings a module, one needs to check if write18 is enabled or not. There are different ways in which this can be done.
  
* A new primitive in pdftex 1.30: <cmd>pdfshellescape</cmd> is a read-only integer that is 1 if <cmd>write18</cmd> is enabled, 0 otherwise.
+
* A new primitive in pdftex 1.30: {{cmd|pdfshellescape}} is a read-only integer that is 1 if {{cmd|write18}} is enabled, 0 otherwise.
* ConTeXt defines <cmd>systemcommandmode</cmd> that is 2 if <cmd>write18</cmd> is enabled, 1 otherwise.
+
* ConTeXt defines {{cmd|systemcommandmode}} that is 2 if {{cmd|write18}} is enabled, 1 otherwise.
* A primitive <cmd>ifeof18</cmd> that is <code>true</code> if <cmd>write18</cmd> is disabled, <code>false</code> otherwise.
+
* A primitive {{cmd|ifeof18}} that is <code>true</code> if {{cmd|write18}} is disabled, <code>false</code> otherwise.
  
<cmd>ifeof18</cmd> works with both pdfTeX and XeTeX, while <cmd>pdfshellescape</cmd> only works with pdfTeX.
+
{{cmd|ifeof18}} works with both pdfTeX and XeTeX, while {{cmd|pdfshellescape}} only works with pdfTeX.
  
 
Hans response on the mailing list
 
Hans response on the mailing list
Line 49: Line 67:
 
\directlua 0 { os.execute("...") }
 
\directlua 0 { os.execute("...") }
 
</texcode>
 
</texcode>
 +
 +
== See also ==
 +
 +
* [[Executesystemcommand]]
 +
 +
[[Category:Installation]]

Latest revision as of 13:27, 9 August 2020

When write18 is turned on, it means that it's possible to execute external programs in the middle of a TeX run. This is required to make some modules such as those for R, lilypond, gnuplot, ... etc. to work properly, but may impose a security leak if you would be running TeX on a server with untrusted sources of TeX files, so it's turned off by default.

How to turn on write18

Windows - MikTeX

MikTeX 2.5/2.6

Each application now has its own configuration file. To enable write18 run

initexmf --edit-config-file=miktex\config\pdftex.ini

or (if you have MikTeX 2.5 or a version of ConTeXt from 2006)

initexmf --edit-config-file=miktex\config\pdfetex.ini

and put

EnableWrite18=t

into it. An alternative is to set the environment variable MIKTEX_ENABLEWRITE18=t.

Windows/Linux/Mac - TexLive

TexLive 2008

Open the file 'path to TexLive'/texmf/web2c/texmf.cnf and search in the file for the following passage:

% Enable system commands via \write18{...}?  Obviously insecure, despite
% being so useful.
shell_escape = f

change here the option from false to true so that the last line above looks like

shell_escape = t

After that you just have to recompile your formats. That is done by

texexec --make --all

or/and

texexec --make --all cont-xx

where xx stands for your needed countrycode. Additionally if you're using MK IV already you have to do the following steps afterwards to get a running environment:

luatools --generate
context --make --all
context --make --all cont-xx

after that write18 sould be enabled and you sould be able to use it.

Linux/Mac

First try to figure out where your configuration file resides:

kpsewhich texmf.cnf

will should return you something like

/usr/local/teTeX/texmf.cnf

or

/usr/local/gwTeX/texmf.cnf

In that file you'll probably find a line reading

shell_escape = f

Change that "f" (false) to "t" (true) to enable it.

How to check if write18 is turned on

Sometimes while writings a module, one needs to check if write18 is enabled or not. There are different ways in which this can be done.

\ifeof18 works with both pdfTeX and XeTeX, while \pdfshellescape only works with pdfTeX.

Hans response on the mailing list

write 18 is a hack and pdfshellescape a sane replacement

in luatex it will probably be gone completely since there we have

\directlua 0 { os.execute("...") }

See also