# How to make the rmligs script available globally on Windows?

Hopefully on-topic as about "(La)TeX related software and tools"

I just learned about the rmligs script. Since it isn't available through MiKTeX (and neither through TeX Live), I downloaded the archive manually and unpacked it. Using Windows command prompt, rmligs runs successfully when I'm in the directory where the file rmligs (without a file extension) is, typing perl rmligs testfile.tex.

Now I tried to make the script available globally, just like e.g. latexmk is, but didn't succeed. How do I make rmligs globally available, so that I can use it no matter in which directory I am?

I tried putting all the rmligs files in a directory in different places, seeking to follow the texmf tree order:

• C:\Program Files (x86)\MiKTeX 2.9\scripts\rmligs\perl\
• C:\Program Files (x86)\MiKTeX 2.9\scripts\rmligs\
• C:\mtpak\scripts\rmligs\perl\ (C:\mtpak\ is my local/personal/custom root, which works for other additions.)
• C:\mtpak\scripts\rmligs\

After each of these attempts, I refreshed the file name database, but calling perl rmligs foo.tex or rmligs foo.tex didn't work.

I'm using ActivePerl 5.12.4 Build 1205 (64-bit) on Windows 7 (64-bit). I'm not an advanced command line user nor a Perl programmer or anything, I installed Perl in the first place to use latexmk.

-
I suspect this may be borderline off-topic, as the issue here is getting Perl to find a script, and the involvement of TeX here is marginal. Basically, it's the Windows path that is going to be important, not the MiKTeX database. – Joseph Wright Dec 8 '11 at 17:54
You could create a bat/cmd file for perl rmligs %1 and add it to the system path. :) – Paulo Cereda Dec 8 '11 at 17:55
Try going to Control Panel\System and Security\System -> Advanced system settings and VERY CAREFULLY adding the folder your script is in to the end of your path. I don't use perl, but this is how you get windows to find an exe file. – Canageek Dec 8 '11 at 17:57
@Joseph: I was hoping to get an answer here for LaTeX users that are Perl-ignorant. I checked on other SO sites briefly, but generally found the Perl questions to be way beyond my knowledge and was afraid to get turned down there as a beginner question, my issue being that I'm not even interested in getting into Perl, I just want to get rmligs running (globally). Then again, many of the questions about "(La)TeX related software and tools like BibTeX, LyX, LaTeX editors, viewers, and converters" may have marginal actual TeX involvement. After all, it looks like the comments are helping already. – doncherry Dec 8 '11 at 18:12
On Björn Jacke’s website is a directory with a more recent version of rmligs. Surprisingly there are not only some new words added, but some other removed. – Speravir Dec 9 '11 at 1:37

My answer has nothing to do with TeX at all, but I hope to answer your question.

In order to run commands on an arbitrary folder, they need to be "known" by the operating system. How do the system know if a command is available? A search in the path. So, first things first:

Extract the content of rmligs-0.84.tar.gz to a folder. I suggest to avoid spaces in directory names. In my case, I extracted to C:\paulo\softwares\rmligs.

If I dir my directory, I have:

14/11/2002  18:54               359 BUGS
14/11/2002  19:19               466 Changes
02/11/1999  18:28            18.007 GPL2
28/11/1999  19:43               269 makefile
14/11/2002  20:06               699 MD5sums
18/03/2000  12:40             2.621 PGPKeys
14/11/2002  17:12            28.799 rmligs
14/11/2002  19:55             1.641 rmligs.1
01/12/1999  09:53               791 testfile.tex
14/11/2002  19:04                 5 VERSION

Now, lets add that directory to the Windows path. As Canageek mentioned, go to Control Panel -> System and Security\System -> Advanced system settings -> Environment settings. For God's sake, take care. :) I usually prefer to change my user variables instead of the system variables, so double-click the PATH variable under user variables, go to the end of the line, type ; and add the full path we set in the previous step:

(Sorry, my Windows is in Portuguese, but I hope you get the idea)

Then click OK a bunch of times. :)

Now let's go to the command prompt:

It didn't work you bastard! I'll explain why. There's a system variable called PATHEXT, if I echo it (it might be different on your computer):

C:\Users\Paulo>echo %PATHEXT%
.SCM;.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.wlua;.lexe;.RB;.RBW

Those are the files which can be executed in the command prompt and their order. As you can see, if you have bla.exe and bla.bat in the path, the first one will be executed because it has a higher priority. Now lets add our rmligs Perl script.

Go to the rmligs directory (in my case, C:\paulo\softwares\rmligs) then create a file called rmligs.cmd (I'm a fan of .cmd instead of .bat) with the following content:

@echo off
perl %~dp0\rmligs %1 %2 %3 %4 %5 %6 %7 %8 %9

Done! Lets break it:

perl is the interpreter, %~dp0\rmligs gives the the full path to the script, and %1 to %9 are the arguments provided to the .cmd script. Great!

Now lets open another command prompt:

Cool take all my money! Now lets test it. I copied testfile.tex to my Documents folder, lets see if it works:

Yay! Hope it helps. :)

-
Not only did you manage to guide me through this process, but you also made me laugh on the way -- twice. Thanks so much! :) – doncherry Dec 8 '11 at 19:18
@doncherry: Thanks a lot for the kind words. :) – Paulo Cereda Dec 8 '11 at 19:36

I have the impression the question is also about the scripts folder in miktex. The miktex bin folder contains a number of small executables (like e.g. makeglossaries.exe, makeluafontdb.exe, htlatex.exe) which are simple wrappers which points to perl scripts or lua scripts or batch files which resides in the miktex/scripts folder.

You can't add your own wrapper .exe and scripts (or change the pathes or names of the existing ones) in this way. For security reasons miktex uses a protected file (scripts.ini) which contains the list of the allowed scripts.

So if you will have to use the usual non-miktex methods like writing a small batch file and then put this batchfile somewhere in your path.

-
Maybe, I’ve mistaken you, but I’ve put the rmligs script into the scripts folder of my LocalTeXMF, and I’ve written a batch, that I’ve put into the bin folder of my LocalTeXMF (which I added to the system wide Windows %PATH%). This works fine for years now, and MiKTeX did never complain about that. – Speravir Dec 9 '11 at 2:20
@Speravir: You are using a normal, non-miktex method (which naturally can use folders in a miktex tree). The .exe in the miktex/bin folder are versions of the runbat.exe or runperl.exe etc which one can find in bin/internal. These runXXX.exe can only be used for applications listed in the scripts.ini. – Ulrike Fischer Dec 9 '11 at 8:33
So, I misunderstood you. Thanks for clarification. – Speravir Dec 10 '11 at 17:36

If you don't like wrapper scripts you can use the two commands:

ASSOC .pl=PerlScript
FTYPE PerlScript=perl.exe %1 %*

This allows you to invoke a Perl script as follows:

script.pl 1 2 3

If you want to eliminate the need to type the extensions, then do the following:

set PATHEXT=.pl;%PATHEXT%

and the script could be invoked as follows:

script 1 2 3

Of course you have to adjust the PATH environment variable as in Paulo Cereda answers. Otherwise the script will not be found.

-