2

My intention is to run a perl script latexdiff.pl from a portable version of perl. There is a batch file portableshell.bat which sets up the environment for perl. If I open it and type perl latexdiff.pl additional_arguments, the program works nicely. However, I want to automate it. I created a batch file useLatexdiff.bat and put the following into it:

portableshell.bat
perl ..\MiKTeX\texmfs\install\scripts\latexdiff\latexdiff.pl

The perl environment is properly set up, but the second line is not executed. How can I achieve to execute the second line?

Note: It is a common question. Another use-case is to open a Unix shell and after that execute Unix commands from that shell.

1 Answer 1

0

Your problem is that a batchfile works as follows: It executes a command and waits for that command to finish before going to the next.

So in your case, it waits at portableshell.bat until it fihishes, which probably does not happen.

Luckily, there are several methods you can do to execute a command and skip to the next one without waiting for the first one to finish. For calling batch files, you can use call filename.bat to call it and immediately skip to the next row.

Your batch file would look like this:

call portableshell.bat
perl ..\MiKTeX\texmfs\install\scripts\latexdiff\latexdiff.pl

If you have executables, such as the perl one that you want to have the same thing happening to, use the command start.

Although the above should work, if it doesn't, you may want to edit the portableshell.bat file and append teh perl command at the very end.

4
  • The problem is that the portableshell.bat probably opens up a shell window that the next command needs to be executed in and outside of that shell window the environment is still not "set up" as it is a portable app. Running perl randomly after the batch fule will probably result in a file not found error. It feels to me that this might be easiest to script using AutoIt or AutoHotkey.
    – Mokubai
    Dec 28, 2017 at 9:20
  • Putting the call command in front did not change anything. @Mokubai I am working on a set of interoperating portable programs on a USB key. Does AutoIt or AutoHotkey need additional programs to work? If possible, I would remain with the Windows command prompt. Dec 28, 2017 at 9:31
  • Can't you just edit the portableshell.bat file, and place the perl command at the very end?
    – LPChip
    Dec 28, 2017 at 9:33
  • @LPChip Thanks, putting the perl command at the end of the portableshell.bat file - although not very modular - works. You may append your answer so that other later users can find it more easily. Dec 28, 2017 at 10:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .