pdflatex 和 shell 脚本

发布于 10-08 19:04 字数 1558 浏览 8 评论 0原文

我需要监视 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

从﹋此江山别2024-10-15 19:04:07

工作目录不正确。我猜测工作目录是 launchd 所在的目录(您可以通过向 shell 脚本添加“pwd”命令来测试它)。您应该更改此设置,或者您可以修改您的 pdflatex 命令:

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

我添加了 -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:

/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.

红颜悴2024-10-15 19:04:07

您似乎没有权限写入文件“test.log”。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文