title: Running a bash script from within Applescript
body: <p>I'm having an issue getting a bash script to execute from within Applescript. What I need is for the Applescript file to prompt for the username and password so that the bash script runs with <code>sudo</code> permissions, as it is doing tasks that cannot be done as an Administrator, such as writing to <code>/etc/</code>.  </p>
  
  <p>As this script (packaged inside a <code>.dmg</code> file using Platypus) will be distributed to a number of users, I can't rely on absolute paths, and instead need to get the path of the Applescript file when it runs, get <code>sudo</code> permissions, and run the bash script from within the same directory.  </p>
  
  <p>So far, everything I have been able to come up with, via SO posts and other sites, has resulted in <code>osascript</code> complaining that it can't find the bash script. Any ideas?</p>
  
  <p>It seems that this might work, but it syntax errors:</p>
  
  <pre><code>set wd to do shell script "pwd"
  
  tell application "Terminal"
      set run_cmd to "/bin/bash " &amp; wd &amp; "/osx.sh"
      do script run_cmd with administrator privileges
  end tell
  </code></pre>