Output to terminal

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

Can you help me ?
Thanks in advance.

  1. 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 ?

  1. 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

Doing things “by hand” in the Terminal, you would use a semicolon:

cd ~; ls

This works the same way in AppleScript:

-- Like this.
do shell script "cd ~; ls"

-- or like this:
tell app "Terminal"
    activate
    do script "cd ~; ls"
end tell

You can also do this:


tell application "Terminal"
    activate
    do script "cd ~" in front window
    do script "ls" in front window
end tell

You could ask the user for the password:

display dialog "Please enter your password:" default answer ""
set thePassword to text returned of result

If you’re using OS X 10.4 (Tiger), you can hide the password:

display dialog "Please enter your password:" default answer "" with hidden answer
set thePassword to text returned of result

Model: Mac mini
AppleScript: 1.10
Browser: Safari 412
Operating System: Mac OS X (10.4)

Thanks for you answers.

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…