title: How to run multiple lines of commands in Terminal from AppleScript?
body: <p>Please refer to this question first,</p>
  
  <p><a href="https://stackoverflow.com/questions/24559703/unable-to-read-opensslv-hno-such-file-or-directory">unable to read opensslv.h:No such file or directory</a></p>
  
  <p>Based on that I need to run the following three line Terminal commands using AppleScript,</p>
  
  <pre><code>/tmp/ssl/openssl-1.0.1h/Configure darwin64-x86_64-cc ––prefix=/usr no-threads shared
  make -f /tmp/ssl/openssl-1.0.1h/Makefile
  sudo make -f /tmp/ssl/openssl-1.0.1h/Makefile install
  </code></pre>
  
  <p>I tried two methods I created text files with <strong><em>.command</em></strong> and <strong><em>.sh</em></strong> extensions and added the above three lines. Then tried to run it from AppleScript as,</p>
  
  <pre><code>do shell script "/Users/Username/Desktop/RunScript.sh"
  </code></pre>
  
  <p>But got this error,</p>
  
  <pre><code>error "/Users/Username/Desktop/RunScript.sh: line 1: /tmp/ssl/openssl-1.0.1h/Configure: No such file or directory
  /Users/Muhriz/Desktop/InstallOpenSSL.sh: line 2: make: command not found sudo: no tty present and no askpass program specified" number 1
  </code></pre>
  
  <p>This could work,</p>
  
  <pre><code>tell application "Terminal" to activate
  tell application "Terminal"
      do script ("/tmp/ssl/openssl-1.0.1h/Configure darwin64-x86_64-cc ––prefix=/usr no-threads shared") in window 1
      do script ("make -f /tmp/ssl/openssl-1.0.1h/Makefile") in window 1
      do script ("sudo make -f /tmp/ssl/openssl-1.0.1h/Makefile install") in window 1
  end tell
  </code></pre>
  
  <p>But it asks for password in Terminal at the third line and waits for user response. The password dialog shown from the AppleScript (when using <code>with administrator privileges</code>) is OK. But it must no ask for password via Terminal when running the commands. It needs to ask only once when the AppleScript is executed and run all <code>sudo</code> related commands without asking for password in Terminal.</p>
  
  <p>What code needs to be used to run from AppleScript?</p>