title: pdflatex and shell script
body: <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 :</p>
  
  <p>1)launchd to monitor my dir, this is my test.plist file</p>
  
  <pre><code>&lt;plist version="1.0"&gt;
  &lt;dict&gt;
      &lt;key&gt;Label&lt;/key&gt;
   &lt;string&gt;DirMonitor&lt;/string&gt;
   &lt;key&gt;ProgramArguments&lt;/key&gt;
   &lt;array&gt;
    &lt;string&gt;/Users/Caffeina/Desktop/test.sh&lt;/string&gt;
    &lt;string&gt;path modified&lt;/string&gt;
   &lt;/array&gt;
   &lt;key&gt;QueueDirectories&lt;/key&gt;
   &lt;array&gt;
    &lt;string&gt;/Users/Caffeina/Desktop/test_dir/&lt;/string&gt;
   &lt;/array&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  
  <p>2) test.sh :</p>
  
  <pre><code>#!/bin/sh
  /usr/texbin/pdflatex -interaction=nonstopmode /Users/Caffeina/Desktop/test_dir/test.tex
  </code></pre>
  
  <p>3) starting the monitor  :</p>
  
  <pre><code>launchctl load /Users/Caffeina/Library/LaunchAgents/test.plist 
  </code></pre>
  
  <p>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 :</p>
  
  <pre><code>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]    !  ==&gt; Fatal error occurred, no output PDF file produced!
      com.apple.launchd.peruser.501[127]  (logger[4155]) Exited with exit code: 1
  </code></pre>
  
  <p>I don't understand why this error, any idea?</p>