title: Pass in variable from shell script to applescript
body: <p>I've got a shell script that I call that uses <code>osascript</code>, and that <code>osascript</code> calls a shell script and passes in a variable that I've set in the original shell script.  I don't know how to pass that variable in from the applescript to shell script.</p>
  
  <p>How can I pass in a variable from shell script to applescript to shell script...?</p>
  
  <p>Let me know if I don't make sense.</p>
  
  <pre><code> i=0
   for line in $(system_profiler SPUSBDataType | sed -n -e '/iPad/,/Serial/p' -e '/iPhone/,/Serial/p' | grep "Serial Number:" | awk -F ": " '{print $2}'); do
   UDID=${line}
   echo $UDID
   #i=$(($i+1))
   sleep 1
  
  
   osascript -e 'tell application "Terminal" to activate' \
   -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' \
   -e 'tell application "Terminal" to do script "cd '$current_dir'" in selected tab of the front window' \
   -e 'tell application "Terminal" to do script "./script.sh ip_address '${#UDID}' &amp;" in selected tab of the front window'
  
   done
  </code></pre>