Hello !
I am trying to make an easy installer for an application. This software requires an installation via the terminal by cding to its folder and typing sudo ./install.sh. Then it displays the installation process into the terminal and the user has got to enter information into the terminal. I wish to ease the ./install.sh process by an easy clickable launcher.
For doing that I created an Applescript application in which I copied the application folder (in Contents/MacOS/). With applescript, I can launch the needed terminal ./install.sh command but the output should be in the terminal window and this is not working (no terminal window appears).
Here is the code of the “main script” of the Applescript Application.
set base_dir to quoted form of (POSIX path of (path to me)) & “Contents/MacOS/”
set app_dir to base_dir & “nameofapplication”
set launch_app to “./install.sh”
do shell script "cd " & app_dir & "; " & launch_app with administrator privileges
Hi again. I found a partial solution. The user must still enter his admin password into the terminal…
Here is the script:
set base_dir to (POSIX path of (path to me)) & “Contents/MacOS/applicationfolder/”
set launch_app to “sudo ./install.sh”
tell application “Terminal”
do script "cd " & base_dir & "; " & launch_app
end tell
If I use a do shell script command, the command is performed in the background without opening a terminal window
If I use a do script command, I cannot use “with administrator privileges” command.
Any workaround ?
Another question is that you should be able to send several commands to one terminal window.
This possibility exists as it is mentionned here: http://developer.apple.com/technotes/tn2002/tn2065.html
“You can script Terminal and send a series of commands to the same window (though this only works in Mac OS X 10.2 and later)”
The question is how do you do this ?
Thanks
Ok but then how do I get admin privilege for my command in the terminal ?
The other problem I have is that my script don’t work if it is in a folder with a space in the name. So I changed my script to “quoted form of posix” but it still doesn’t work. Any ideas ?
set base_dir to quoted form of (POSIX path of (path to me)) & "Contents/MacOS/applicationfolder/"
set launch_app to "sudo ./install.sh"
tell application "Terminal"
do script "cd " & base_dir & "; " & launch_app
end tell
The idea was to give input to the shell software once launched which requires some user interaction i.e. click yes, enter path etc…