pdflatex 和 shell 脚本
我需要监视 osx 中的特定目录更改,以便查看文件是否已上传,当文件位于目录内时,我想运行一个非常基本的脚本(只需使用 pdflatex '编译' .tex 文件),什么到目前为止我已经完成了:
1)launchd来监视我的目录,这是我的test.plist文件
<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:3
#!/bin/sh
/usr/texbin/pdflatex -interaction=nonstopmode /Users/Caffeina/Desktop/test_dir/test.tex
)启动监视器:
launchctl load /Users/Caffeina/Library/LaunchAgents/test.plist
4)测试一切是否正常工作我在受监视的内部移动一个文件dir....但什么也没发生。查看控制台输出,我可以红色此错误:
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 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?
工作目录不正确。我猜测工作目录是 launchd 所在的目录(您可以通过向 shell 脚本添加“pwd”命令来测试它)。您应该更改此设置,或者您可以修改您的 pdflatex 命令:
我添加了
-output-directory=/tmp
,我现在假设您具有对 /tmp 的读写访问权限。如果有效,则问题出在写入权限上。然后您可以尝试获得正确的输出目录。您可以通过 launchd 或 shell 脚本中的“cd myDir”来完成此操作。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:
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.