Support with Applescript

Discussion in 'Mac Programming' started by Haribo98, May 6, 2012.

  1. macrumors newbie

    May 6, 2012
    Hi. I'm currently working on a Project for a Game. And I'm stumped on what to do next.
    I mean, I know what I want to do, but I don't know how to do it.

    I want to run a Shell Script that downloads a bunch of Shell Scripts into ~/Library/Application Support/minecraftmodinstaller/

    So far, I've written the scripts but don't know how to implement them.
    I would also like to know how I could link the downloaded scripts to buttons in Xcode. I have made the links but don't know the code to make the button open them.

    My scripts can be found here. They're reasonably long...

    And the Downloader script can be found here.

    P.S - This App is Written in Cocoa-Applescript

    Thanks in Advance
    - Harry
  2. kryten2, May 6, 2012
    Last edited: May 6, 2012

    macrumors 6502a

    Mar 17, 2012
  3. Haribo98, May 7, 2012
    Last edited: May 7, 2012

    thread starter macrumors newbie

    May 6, 2012
    Thanks! And my website does that. It works for some people and not for others.


    Ok, new problem. When I try and run my Script. I get this error.
    "Command /usr/bin/osacompile failed with exit code 1"

    Here is my Code.
    on clicked theObject
            if title of theObject = "Update Installers!" then
                run shell script "rm -rf ~/MCInstaller/scripts/; mkdir ~/MCInstaller/; mkdir ~/MCInstaller/scripts/; cd ~/MCInstaller/scripts/; curl -O; unzip -d ~/MCInstaller/scripts/; rm -rf ~/MCInstaller/scripts/__MACOSX/; rm -f ~/MCInstaller/scripts/"
            end if
        end clicked
    Is it because I included the tilde (~) in my Shell Script? I was going to try, but I didn't know what would replace it. Which is why I was going to try and make them as Workflows. But I didn't know how to open them from within the App.

    Eg. I have a Workflow/Script in my Resources folder of the App. But when I drag the file into the Code. It links to it as though I was pulling it in from the Finder.
  4. kryten2, May 7, 2012
    Last edited: May 7, 2012

    macrumors 6502a

    Mar 17, 2012
    I've only made some very simple little apps in Xcode 3 myself and barely scratched the surface of Applescript. I think your run shell script causes the error, you can run .scpt files but not run shell script. Try this line in Script Editor and check if things are removed, folders created, curl line works etc. If it works you can adjust your code.

    do shell script "rm -rf ~/MCInstaller/scripts/; mkdir -p ~/MCInstaller/scripts;  cd ~/MCInstaller/scripts/; curl -O; unzip -d ~/MCInstaller/scripts/; rm -rf ~/MCInstaller/scripts/__MACOSX/; rm -f ~/MCInstaller/scripts/"
    The two mkdir lines can be replaced by one by using the -p option. The tilde (~) points to your home directory eg. /Users/username. You can run workflows with this code :

    -- change line below to where you saved your .workflow
    set workflowpath to "Macintosh HD:Users:martin:Desktop:Example.workflow"
    set qtdworkflowpath to quoted form of (Posix path of workflowpath)
    set command to "/usr/bin/automator -v " & qtdworkflowpath
    set output to do shell script command
  5. macrumors 6502

    May 29, 2011
    Littleton, Colorado, USA
    I am not able to access your project to look, but on clicked theObject is an AppleScript Studio handler, which will result in a compile error when building the project if you are using current versions of Xcode with AppleScriptObjC (AppleScript Studio is deprecated as of Snow Leopard).

    What OS/Xcode versions are you using? Can you post a smaller example or use a different host that is reliable?

Share This Page