I need to use the Apple choose file dialog to select a file to use in a bash script. I believe the only way to do this is in AppleScript. I would like to call an AppleScript from within bash, and have it return the location of the selected file as a variable to be used in the shell script. So far I have:
osascript <<EOF
tell Application "Finder"
set strPath to "/my/default/location/"
set thePDF to file (choose file with prompt "Choose a PDF: " of type { " com.adobe.pdf" , "dyn.agk8ywvdegy" } without invisibles default location strPath) as alias
set PDFName to name of file thePDF
end tell
EOF
How do I now pass the location of the PDF - the AppleScript variable PDFName - back to the Shell?