Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old May 6, 2012, 06:42 AM   #1
Haribo98
macrumors newbie
 
Join Date: May 2012
Support with Applescript

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
Haribo98 is offline   0 Reply With Quote
Old May 6, 2012, 10:09 AM   #2
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
In Xcode 3.x.x an on clicked theObject handler would to the trick. Things changed with Xcode 4. Check out http://macscripter.net/viewtopic.php?id=30274

Code:
on clicked theObject
	if title of theObject = "" then
-- run/open your script
end if
end clicked
ps : Your links result in this : Safari can’t open the page “http://mossycc.com/Latest/installersdl.zip” because Safari can’t find the server “mossycc.com”.

Last edited by kryten2; May 6, 2012 at 10:15 AM.
kryten2 is offline   0 Reply With Quote
Old May 7, 2012, 02:57 AM   #3
Haribo98
Thread Starter
macrumors newbie
 
Join Date: May 2012
Quote:
Originally Posted by kryten2 View Post
In Xcode 3.x.x an on clicked theObject handler would to the trick. Things changed with Xcode 4. Check out http://macscripter.net/viewtopic.php?id=30274

Code:
on clicked theObject
	if title of theObject = "" then
-- run/open your script
end if
end clicked
ps : Your links result in this : Safari can’t open the page “http://mossycc.com/Latest/installersdl.zip” because Safari can’t find the server “mossycc.com”.
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.
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 http://mossycc.com/Latest/installers.zip; unzip installers.zip -d ~/MCInstaller/scripts/; rm -rf ~/MCInstaller/scripts/__MACOSX/; rm -f ~/MCInstaller/scripts/installers.zip"
        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.

Last edited by Haribo98; May 7, 2012 at 03:01 AM. Reason: Forgot the last bit.
Haribo98 is offline   0 Reply With Quote
Old May 7, 2012, 08:54 AM   #4
kryten2
macrumors 6502a
 
Join Date: Mar 2012
Location: Belgium
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.

Code:
do shell script "rm -rf ~/MCInstaller/scripts/; mkdir -p ~/MCInstaller/scripts;  cd ~/MCInstaller/scripts/; curl -O http://mossycc.com/Latest/installers.zip; unzip installers.zip -d ~/MCInstaller/scripts/; rm -rf ~/MCInstaller/scripts/__MACOSX/; rm -f ~/MCInstaller/scripts/installers.zip"
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 :

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

Last edited by kryten2; May 7, 2012 at 09:24 AM.
kryten2 is offline   0 Reply With Quote
Old May 7, 2012, 10:30 AM   #5
Red Menace
macrumors 6502
 
Join Date: May 2011
Location: 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?
__________________
MacBook Pro / OS X Mavericks (10.9.4) / Xcode 5.1.1 / RubyMotion FTW
Red Menace is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
AppleScript Support Comes Back to Numbers, Could Signal a Return of Power User Features MacRumors Mac Blog Discussion 42 Jan 30, 2014 08:22 PM
AppleScript: How do I save multiple Excel sheets to one pdf using Applescript sbtaylor1 Mac Programming 0 Oct 28, 2013 11:38 PM
AppleScript: How do I save multiple Excel sheets to one pdf using Applescript sbtaylor1 Mac Applications and Mac App Store 0 Oct 28, 2013 11:32 PM
U.S. Carriers Unlikely to Support iPhone 5's Wideband Audio, European Support More Likely MacRumors MacRumors.com News Discussion 127 Jan 9, 2013 09:22 PM
support full-screen for iPhone5 with support iOS from 3.2 sebasx iPhone/iPad Programming 5 Nov 29, 2012 08:23 PM

Forum Jump

All times are GMT -5. The time now is 01:14 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC