开发者

pdflatex and shell script

开发者 https://www.devze.com 2023-01-31 15:26 出处:网络
I need to watch for a specific directory changes in osx, in order to see if a file was uploaded, when the file is inside the dir i want to run a very basic script(simply \'compile\' .tex files using p

I need to watch for a specific directory changes in osx, in order to see if a file was uploaded, when the file is inside the dir i want to run a very basic script(simply 'compile' .tex files using pdflatex), what I've done so far :

1)launchd to monitor my dir, this is my test.plist file

<plist version="1.0">
<dict>
    <key>Label</key>
 <string>DirMonitor</string>
 <key>ProgramArguments</key>
 <array>
  <string>/Users/Caffeina/Desktop/test.sh</string>
  <string>path modified</string>
 </array>
 <key>QueueDirectories</key>开发者_开发知识库;
 <array>
  <string>/Users/Caffeina/Desktop/test_dir/</string>
 </array>
</dict>
</plist>

2) test.sh :

#!/bin/sh
/usr/texbin/pdflatex -interaction=nonstopmode /Users/Caffeina/Desktop/test_dir/test.tex

3) starting the monitor :

launchctl load /Users/Caffeina/Library/LaunchAgents/test.plist 

4) to test if all is working properly I move a file inside the monitored dir.... but nothing happen. Looking into the console output i can red this error :

logger[4155]    This is pdfTeX, Version 3.1415926-1.40.11 (TeX Live 2010)
logger[4155]    restricted \write18 enabled.
logger[4155]    entering extended mode
logger[4155]    ! I can't write on file `test.log'.
logger[4155]    (Press Enter to retry, or Control-D to exit; default file extension is `.log')
logger[4155]    Please type another transcript file name
logger[4155]    ! Emergency stop
logger[4155]    !  ==> Fatal error occurred, no output PDF file produced!
    com.apple.launchd.peruser.501[127]  (logger[4155]) Exited with exit code: 1

I don't understand why this error, any idea?


The working directory is not correct. I would guess working directory is the one where launchd is located (you can test it by adding the 'pwd' command to shell script). You should change this, or you could modify your pdflatex command:

/usr/texbin/pdflatex -interaction=nonstopmode -output-directory=/tmp /Users/Caffeina/Desktop/test_dir/test.tex

I added -output-directory=/tmp, I now assume that you have read and write access to /tmp. If this works, problem was with the write permissions. You could then play around to get the correct output dir. You could do it either through launchd or just 'cd myDir' in shell script.


It seems that you have no permissions to write on file `test.log'.

0

精彩评论

暂无评论...
验证码 换一张
取 消