# [tex-live] TeXLive (Windows) bash script -> exe

Reinhard Kotucha reinhard.kotucha at web.de
Tue May 20 00:23:01 CEST 2014

On 2014-05-19 at 21:22:46 +0200, Josef Kleber wrote:

> Am 19.05.2014 19:47, schrieb Mojca Miklavec:
> >
> > (Cynicism aside, you should really learn lua or ask for step-by-step
> > help on the mailing list. Particularly with your complexity of the
> > script, it should be trivial to port it to lua and preserve all the
> > headaches for everyone else.)
> >
>
> construct the URL also on the LaTeX side. So it should be doable
> even for me! ;-)
>
> To download the map with a LaTeX command i would still need
>
> \immediate\write18{texlua osmimage.lua}
>
> Right? Or am i missing something?

Well, this doesn't work because texlua doesn't know where in the TEXMF
tree osmimage.lua is installed.  You have to write:

\immediate\write18{osmimage}

On Unix osimage is a symlink to osmimage.lua and on Windows
osmimage.exe passes its arguments to runscript.tlu, which determines
the location of your script and finally executes it.  runscript.tlu is
executed by texlua, which in turn has kpathsea built-in.

All this is described in detail in  bin/win32/runscript.tlu .
If you don't have binaries for Windows on your machine, see

http://tug.org/svn/texlive/trunk/Master/bin/win32/runscript.tlu

> Perhaps not the right place to ask, but the above should also work
> with MiKTeX, right?

It should be sufficient to upload the script to CTAN.  You don't have
to worry about symlinks and wrappers for TeX Live.  I'm sure that
Christian will do the right thing in order to install your script
properly in MiKTeX.

Another interesting solution would be to put the Lua code directly
into the LaTeX file.  Since LuaTeX is based on pdfTeX, the only
restriction is that XeTeX users are excluded.  But a self-contained
package has some advantages too.  In order to see how easy it is,
look at my minimal example:

http://tug.org/~kotucha/luatab.pdf

A very similar example appeared in the latest issue of TUGboat.
The luacode package solves most of the nasty \catcode problems.

> construct the URL also on the LaTeX side. So it should be doable
> even for me! ;-)

BTW, if you assemble the URL on the LaTeX side, how do you read
command-line arguments?  It's probably easier to do this in Lua.
Honestly, *everything* is easier in Lua.

The definite guide is the book "Programming in Lua".  Only the first
edition (Lua 5.0) is available online.  Most of the content is still
valid.  If in doubt, consult the Reference Manual.

http://www.lua.org/pil/contents.html

The Lua 5.2 Reference Manual

http://www.lua.org/manual/5.2/

The Tutorial Wiki

http://lua-users.org/wiki/TutorialDirectory

After all, the book "Programming in Lua", 3rd edition, ISBN 859037985X,
is definitely worth it's money.

In order to see which modules and extensions are avalable in texlua and
luatex, run

texdoc luatex

There are a few useful extensions.

Regards,
Reinhard

--
----------------------------------------------------------------------------
Reinhard Kotucha                                      Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                              mailto:reinhard.kotucha at web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------