Apple - How to pass variables from bash script to AppleScript

This should work:

while read urls
do 
    osascript -e "tell application \"Safari\" to open location \"$urls\""
done<file.txt

The quotes don't expand the variable in AppleScript. What you need to do is ESCAPE the quotes:

'tell current tab to open location \"$urls\"`

However, a better way to do this is using run argv. For example:

#!/bin/bash
url="foobar.com"
osascript -e 'on run {myurl}' -e 'tell application "Safari" to set the URL of the document to myurl' -e 'end run' $url 

My preference is to use a separate script for the AppleScript. In bash, this would look like:

#!/bin/bash
osascript -e 'do scriptname \"$url\"'