Welcome to Dream.In.Code
Getting Help is Easy!

Join 131,771 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,108 people online right now. Registration is fast and FREE... Join Now!




Rails and Applescript Question

 
Reply to this topicStart new topic

Rails and Applescript Question

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


New D.I.C Head

*
Joined: 11 Feb, 2007
Posts: 10


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

Go to the top of the page

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


Barbarbar

Group Icon
Joined: 3 Oct, 2006
Posts: 1,255



Thanked 14 times

Dream Kudos: 650
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

Go to the top of the page

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


New D.I.C Head

*
Joined: 11 Feb, 2007
Posts: 10


My Contributions


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

Go to the top of the page

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


Barbarbar

Group Icon
Joined: 3 Oct, 2006
Posts: 1,255



Thanked 14 times

Dream Kudos: 650
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

Go to the top of the page

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


D.I.C Regular

Group Icon
Joined: 9 Aug, 2007
Posts: 314



Thanked 12 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 online!Profile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/20/08 01:47PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month