0

I would like to start a shell script from LaTeX. In the shell script I need to wait until the .pdf file is generated and afterwards I want to do some stuff with this file.

So I created a MWE Test.tex like this:

\documentclass{article}
\immediate\write18{/myPath/script.sh}
\begin{document}
  Test
\end{document}

The shell script script.sh looks like this:

#!/bin/bash
until [ -f Test.pdf ]
do
     sleep 5
done
echo "File found"
# Do SOMETHING

Unfortunately this seems not to work with TeXMaker. It seems to hang in an endless loop and probably the sleep 5 cmd seems also to let TeXMaker fall asleep.

BTW --shell-escape is enabled and chmod 755 script.sh is set.

EDIT Now I'm able to use arara like this in my MWE:

\documentclass{article}
% arara: pdflatex: {shell: yes,synctex: yes,interaction: nonstopmode}
\begin{document}
Test
\end{document}

But how to tell arara now to run this script \immediate\write18{/myPath/script.sh} after the pdf is generated?

5
  • 1
    no that won't work. Why don't you use an external script that first calls pdflatex and then your postprocessing? You could e.g. use arara to set this up. Commented Feb 24, 2023 at 11:09
  • Hmm that‘s a pity. I would like to combine this scripting with my normal workflow in TexMaker. Otherwise I have to execute the external script after every TexMaker build. Or do you know a possibility to have a post build script execution in TexMaker?
    – PascalS
    Commented Feb 24, 2023 at 12:09
  • See for example tex.stackexchange.com/questions/107989/… and other questions.
    – cabohah
    Commented Feb 24, 2023 at 12:37
  • If texmaker is able to run builds combining pdflatex + bibtex +makeindex then it should also be able to run other tools and scripts. Commented Feb 24, 2023 at 12:40
  • I have edited my question, could you please have a look :)
    – PascalS
    Commented Feb 24, 2023 at 15:15

1 Answer 1

0

Thanks for the comments, at the end the solution is much easier than expected.

I had to change my IDE from TexMaker to TexStudio. In TexStudio you just has to add one single expression in the Meta Commands in Preferences => Generate => Build and View.

Meta commands

In my case it's sh -c "/MyPath/script.sh argument1"

That's it!

You must log in to answer this question.

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