I just recently had a need to do this from a bash script. This will also work in Mac OS X, since it supports bash and the curl utility:
Go to the Dropbox developer console (https://www.dropbox.com/developers/apps), login to your Dropbox account, and click the "Create App" button. In the settings for your app, scroll to the OAuth2 section and click the "Generate" button under "Generated access token". You'll need this token to access the Dropbox API.
In your bash script, insert the following:
DROPBOX_TOKEN="<your dropbox token generated in step 1>"
FILENAME="<file you want to share>"
JSON=`curl -s --header "Authorization: Bearer $DROPBOX_TOKEN" \
--header "Content-Type: application/json" \
--data "{\"path\": \"/$FILENAME\",\"settings\": {\"requested_visibility\": \"public\"}}" \
https://api.dropbox.com/2/sharing/create_shared_link_with_settings`
This will give you back a JSON response containing information about the link. You'll need to parse out the JSON response to get the url, which you can do with a simple sed or awk script.
NOTE: The link you get back from this can be shared publicly, but be aware that the access token you got from the developer console is not to be shared. If your script is going to be accessible by someone other than you (the owner of the Dropbox account), then you'll need to take additional steps to authenticate the user with OAuth instead of using the generated token. In my case, the script runs on my machine and just sends the generated links out through an automated process, so the script is not visible to anyone but me. Anyone with that access token will have full control of your Dropbox account through the API, so treat it like you would a password.