3
votes

I have a shell script to generate two types of reports. Each report is generated by executing a Sweave script and then compiling a PDF out of the resulting tex file.

eval "R CMD Sweave Weekly.Rnw"
eval "pdflatex Weekly.tex"
eval "R CMD Sweave Daily.Rnw"
eval "pdflatex Daily.tex"

For instance, if there is an error when executing 'R CMD Sweave Weekly.Rnw', it exits but still generates a tex file (which I have checked cannot be stopped) and this tex file would not compile correctly in pdflatex i.e. 'pdflatex Weekly.tex' command would hang and the shell script will not move to the next 'R CMD Sweave Daily.Rnw'.

Now, my question: If I know that a certain shell command should not take more 30 secs, is there a way to induce a timed exit from that command (assuming it hung) after say a couple minutes (or some arbitrary time lapse)? Alternatively, is there a way to force shutdown a latex engine after it encounters errors when compiling a tex file?

3
Why are you using eval? As the bash faq says "eval is a misspelling of evil, if the answer is eval, you are asking the wrong question"SiegeX
There are contexts where eval is appropriate; it is very far from clear that this is one of them.Jonathan Leffler

3 Answers

3
votes

Use pdflatex -halt-on-error to stop pdflatex from asking questions.

2
votes

See R.utils::evalWithTimeout or setTimeLimit - these can interrupt commands, shell or otherwise, I believe, when a timeout is reached and as long as the command can be interrupted by the user.

0
votes

Or, if that pdflatex is being called from R CMD check, and you don't know how to pass arguments to pdflatex, and you are using Windows, then an alternative is :

  • Start->Programs->MikTex 2.9->Maintenance (Admin)->Settings (Admin)

and then :

  • Click Refresh FNDB
  • Click Update Formats
  • Change Install missing packages on-the-fly to No

This should fix the R CMD check appears to hang error on "checking re-building of vignette PDFs ..." or "checking PDF version of manual ..." problem.