Running Ruby Program from Mac OS X Desktop

Discussion in 'Ruby' started by Alex DeCaria, Aug 1, 2007.

  1. Alex DeCaria

    Alex DeCaria Guest

    I have a Ruby program on my Mac desktop and when I double click on it,
    it doesn't run the program...it just opens up the text editor. How do I
    make it run the program when I double click on it?
    --
    Posted via http://www.ruby-forum.com/.
    Alex DeCaria, Aug 1, 2007
    #1
    1. Advertising

  2. Alex DeCaria

    Ari Brown Guest

    You need to use the command line. Open up Applications -> Utilities -
    > Terminal, and the type 'cd Desktop'. then type 'ruby YOUR PROGRAM'



    HTH,
    Ari


    On Jul 31, 2007, at 9:54 PM, Alex DeCaria wrote:

    > I have a Ruby program on my Mac desktop and when I double click on it,
    > it doesn't run the program...it just opens up the text editor. How
    > do I
    > make it run the program when I double click on it?
    > --
    > Posted via http://www.ruby-forum.com/.
    >
    >


    -------------------------------------------------------|
    ~ Ari
    crap my sig won't fit
    Ari Brown, Aug 1, 2007
    #2
    1. Advertising

  3. Alex DeCaria

    John Joyce Guest

    You need to set the permissions to make it executable.
    You may also need to use Get Info to set the app to open it with. If
    so, try setting it to open with terminal.
    On Jul 31, 2007, at 9:15 PM, Ari Brown wrote:

    > You need to use the command line. Open up Applications -> Utilities
    > -> Terminal, and the type 'cd Desktop'. then type 'ruby YOUR PROGRAM'
    >
    >
    > HTH,
    > Ari
    >
    >
    > On Jul 31, 2007, at 9:54 PM, Alex DeCaria wrote:
    >
    >> I have a Ruby program on my Mac desktop and when I double click on
    >> it,
    >> it doesn't run the program...it just opens up the text editor.
    >> How do I
    >> make it run the program when I double click on it?
    >> --
    >> Posted via http://www.ruby-forum.com/.
    >>
    >>

    >
    > -------------------------------------------------------|
    > ~ Ari
    > crap my sig won't fit
    >
    >
    John Joyce, Aug 1, 2007
    #3
  4. Alex DeCaria

    Bill Dolinar Guest

    On Jul 31, 2007, at 7:54 PM, Alex DeCaria wrote:

    > I have a Ruby program on my Mac desktop and when I double click on it,
    > it doesn't run the program...it just opens up the text editor. How
    > do I
    > make it run the program when I double click on it?
    > --


    It kind of depends on what your looking for. If your wanting to run
    a script that has text IO on screen then you would probably want to
    run it through the terminal. If you want a GUI app then you probably
    want to check out RubyCocoa (http://rubycocoa.sourceforge.net/). If
    everything would happen in the background with no interface, it's
    possible to throw a ruby script in the application package and you
    could double click on it to start the script. For an example Xcode
    project check out http://billdolinar.com/files/SillyBalls.tgz. To
    get the sample to run you build the project from Xcode and then go to
    the "build/Release" folder within the project folder and double click
    on the built app. The script that's being run is in the SillyBalls
    file. To have your script run in the background you would want to
    turn on the LSBackgroundOnly property list key for the app bundle.

    Bill
    Bill Dolinar, Aug 1, 2007
    #4
  5. Alex DeCaria

    12 34 Guest

    Alex DeCaria wrote:
    > I have a Ruby program on my Mac desktop and when I double click on it,
    > it doesn't run the program...it just opens up the text editor. How do I
    > make it run the program when I double click on it?


    Look at Platypus which does exactly what you want.
    http://www.sveinbjorn.org/platypus

    Also look at the Double-Clickable Example section in
    http://www.macdevcenter.com/lpt/a/4954 which uses Pashua
    http://www.bluem.net/downloads/pashua_en/.

    I've started to put together some notes on this since I've been delving
    into the same subject.
    http://knobby.ws/wordpress/2007/07/30/easy-gui-for-ruby-on-a-mac-draft/
    --
    Posted via http://www.ruby-forum.com/.
    12 34, Aug 1, 2007
    #5
  6. Alex DeCaria

    matt neuburg Guest

    Alex DeCaria <> wrote:

    > I have a Ruby program on my Mac desktop and when I double click on it,
    > it doesn't run the program...it just opens up the text editor. How do I
    > make it run the program when I double click on it?


    You need to give the program the .command extension and set it to open
    in the Terminal. Example:

    #!/usr/bin/env ruby
    puts "Hello, world!"

    Save that as hello.command. Use the Terminal (or whatever) to make
    hello.command executable by user. Use Get Info in the Finder to specify
    that hello.command should open with Terminal.

    That's all. Now when you double-click hello.command in the Finder, it
    will run in the Terminal:

    mattneub$ /Users/mattneub/Desktop/hello.command; exit
    Hello, world!
    logout
    [Process completed]

    m.

    --
    matt neuburg, phd = , http://www.tidbits.com/matt/
    Tiger - http://www.takecontrolbooks.com/tiger-customizing.html
    AppleScript - http://www.amazon.com/gp/product/0596102119
    Read TidBITS! It's free and smart. http://www.tidbits.com
    matt neuburg, Aug 1, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. SoftwareDummy
    Replies:
    1
    Views:
    464
    SoftwareDummy
    Dec 4, 2003
  2. cs
    Replies:
    2
    Views:
    423
  3. Nick Palmer
    Replies:
    1
    Views:
    377
    Scott Allen
    Apr 12, 2004
  4. TC
    Replies:
    4
    Views:
    624
    JohnnyAppleseed
    Feb 7, 2005
  5. iMath
    Replies:
    7
    Views:
    562
    iMath
    Nov 10, 2013
Loading...

Share This Page