School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,369 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,440 people online right now. Registration is fast and FREE... Join Now!




Rails and Applescript Question

 

Rails and Applescript Question

fireknite

9 Oct, 2008 - 11:32 AM
Post #1

New D.I.C Head
*

Joined: 11 Feb, 2007
Posts: 11


My Contributions
Writing a web application using Ruby on Rails for my work. Trying to figure out a way to incorporate AppleScript with it do launch a specific program when a button is clicked on the client machine.

Got it to where Ruby and AppleScript are talking to one another, but the AppleScript stuff ends up getting executed on the Server which is hosting the Ruby on Rails web app, not the client system. Below's what I've got so far:

CODE

  require 'rubygems'
  require 'applescript'

  def administratorTools
    AppleScript.say "This is a test"
    script = 'tell application "Safari"
        activate
    end tell'
    AppleScript.execute(script)
    
  end


Any help would be great, thanks!

User is offlineProfile CardPM
+Quote Post


girasquid

RE: Rails And Applescript Question

10 Oct, 2008 - 06:57 AM
Post #2

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,628



Thanked: 53 times
Dream Kudos: 825
My Contributions
You can't run applescript on a visitor's computer - it would be a huge security issue if you could.
User is offlineProfile CardPM
+Quote Post

fireknite

RE: Rails And Applescript Question

12 Oct, 2008 - 07:50 PM
Post #3

New D.I.C Head
*

Joined: 11 Feb, 2007
Posts: 11


My Contributions
Yea I had a feeling that's what people were going to say. =/.
User is offlineProfile CardPM
+Quote Post

girasquid

RE: Rails And Applescript Question

12 Oct, 2008 - 08:09 PM
Post #4

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,628



Thanked: 53 times
Dream Kudos: 825
My Contributions
Yup - some quick Googling mentions an "applescript://" URL, but I'm afraid I haven't played with it much at all - you may want to look into that.
User is offlineProfile CardPM
+Quote Post

MitkOK

RE: Rails And Applescript Question

13 Oct, 2008 - 12:58 AM
Post #5

D.I.C Regular
Group Icon

Joined: 9 Aug, 2007
Posts: 356



Thanked: 19 times
Dream Kudos: 250
My Contributions
If you want simple app execution in ruby you can use system:

QUOTE
system(cmd [, arg, ...]) => true or false
Executes cmd in a subshell, returning true if the command was found and ran successfully, false otherwise. An error status is available in $?. The arguments are processed in the same way as for Kernel::exec.


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 09:01PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month