If you want to do this and do not want to use your Dropbox “Public” folder, the best way to be able to script it reliably is to set up https://github.com/andreafabrizi/Dropbox-Uploader on your system.
It is a bash script which requires about 10 minutes of initial setup, but once you have done that, it gives you a lot of functionality to interact with your Dropbox account via scripting (it does more than its name implies).
For example, if I had a file “foo” in a folder “txt” inside my Dropbox folder, I would do this to get to the share link:
dropbox_uploader.sh share txt/foo.txt | awk '{print $NF}'
No GUI scripting required. The Dropbox.app doesn’t even have to be running!