Deploying "double-clickable" ruby scripts on OSX

P

Phil Henley

I have a menu driven ruby script to copy some files from servers to
local machines.

I'd like to be able to deploy this to OSX users in as pain-free a way as
possible... preferably they could just double click the script and have
it launch in Terminal and do its thing.

I've tried accomplishing this a few different ways and ran into some
problems. Here's a quick breakdown:

1. Tried associating "Terminal.app" to .rb files via the OSX Get Info
dialog and adding a reference to the ruby shell at the top of the
script. This works, but the script needs to reference its current
location via the Dir.getwd method and this method always returns the
users Home folder (regardless of the scripts actual location) when it is
ran this way.

2. Tried simply renaming the script and giving it the '.command'
extension along with a reference to the ruby shell. This works, but has
the same problem as associating .rb files to Terminal.

3. Tried using script-to-app converters such as Platypus and ScriptGUI.
Platypus doesn't allow me to interact with my scripts menu and ScriptGUI
is returning errors that I could maybe iron out, but it doesn't really
seem worth the battle.

Any ideas how to get around this problem? Seems like I might need to
find a different approach to getting the current working directory. I'd
just prefer not to go mucking around with those parts of the script as
they work fine on Windows and also when ran from Terminals command line
on OSX.
 
X

Xavier Noria

Instead of the cwd you seem to need File.dirname(__FILE__).

Top-posted from my iPhone
 
P

Phil Henley

Xavier Noria wrote in post #977824:
Instead of the cwd you seem to need File.dirname(__FILE__).

Top-posted from my iPhone

That works and is a very simple change, thank you!!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,740
Latest member
JudsonFrie

Latest Threads

Top