I'm having an issue getting a bash script to execute from within Applescript. What I need is for the Applescript file to prompt for the username and password so that the bash script runs with sudo permissions, as it is doing tasks that cannot be done as an Administrator, such as writing to /etc/.
As this script (packaged inside a .dmg file using Platypus) will be distributed to a number of users, I can't rely on absolute paths, and instead need to get the path of the Applescript file when it runs, get sudo permissions, and run the bash script from within the same directory.
So far, everything I have been able to come up with, via SO posts and other sites, has resulted in osascript complaining that it can't find the bash script. Any ideas?
It seems that this might work, but it syntax errors:
set wd to do shell script "pwd"
tell application "Terminal"
set run_cmd to "/bin/bash " & wd & "/osx.sh"
do script run_cmd with administrator privileges
end tell
do shell scriptcommand. And relative paths can simply be created with the severalpath to...forms. Where is the bash script located?