title: running sudo command in bash script and running it with launchd
body: <p>I have a bash script that I would like to run with a launchd plist file on OS X. The problem I have is is that the bash script contains sudo commands and it is stopping it from running. So for example my bash script looks like this:</p>
  
  <pre><code>#!/bin/bash
  sudo /opt/local/bin/bindfs -u user1 /Library/WebServer/Documents/user1 /vhosts/user1/public_html
  sudo /opt/local/bin/bindfs -u user2 /Library/WebServer/Documents/user2 /vhosts/user2/public_html
  </code></pre>
  
  <p>and my com.test.bindfs.plist file looks like this (created with Lingon):</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
  &lt;plist version="1.0"&gt;
  &lt;dict&gt;
      &lt;key&gt;GroupName&lt;/key&gt;
      &lt;string&gt;admin&lt;/string&gt;
      &lt;key&gt;Label&lt;/key&gt;
      &lt;string&gt;com.jamespayne.bindfs&lt;/string&gt;
      &lt;key&gt;ProgramArguments&lt;/key&gt;
      &lt;array&gt;
          &lt;string&gt;/usr/bin/bindfs.sh&lt;/string&gt;
      &lt;/array&gt;
      &lt;key&gt;RunAtLoad&lt;/key&gt;
      &lt;true/&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  
  <p>I have checked to see that the script works by running it after startup and entering a password but it wont run at startup. The launchd plist is running but it comes up with the following error:</p>
  
  <p>sudo: no tty present and no askpass program specified</p>
  
  <p>Anybody know how to get this working or why I might get that error. Thanks.</p>