[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

How do I make an autonomous program?

Todd Jacobus

8/23/2008 4:44:00 AM

First, I would like to ask you all to excuse a Ruby-newbie question.
I'm very new to Ruby and, in fact, very new to programing at all. But
anyway...

I've finally finished this program which reads latitude and longitude
data, and various other attributes, from a file and formats it
automatically so that it can be imported into some GIS software. It's
an awesome program, but how do I make it autonomous, so that it doesn't
have to rely on the interpreter? Or rather, how can I get the program
and the Ruby interpreter to work together away from the path in which I
installed it?

I'd really appreciate the advice. I've exhausted all on-line tutorials
I can find, and I'd rather not ask my supervisor to download Ruby so he
can use the program.... Thanks!

Todd
--
Posted via http://www.ruby-....

9 Answers

Adam Akhtar

8/23/2008 5:00:00 AM

0

im a newb too so forgive me if my answer isnt what your looking for.

Do you mean youd like to be able to juts call the script anywhere you
want i.e. outside of the scripts path..

i think its something to do with

load path

google that or do a search on here for that

As a side note the best book ive read so far for ruby newbys is
"Everyday scripting with Ruby" - it has a chapter on this as well. I
havent quite finished the book yet and its one of the later chapters but
give it a look. Its not a reference and has exercises for you to
practice what youve learned. You also find yourself going away
experimenting with code as you read his examples as well.
Its a bit more (only a bit though) advanced than learning to program by
c.pine though. Also its all about scripting and writing scripts that are
"useful" e.g. webscraping amazon etc.

I think those two books should be read by every beginner
--
Posted via http://www.ruby-....

Todd Jacobus

8/23/2008 5:22:00 AM

0

Well that sounds like what I'm looking for. All I want to do is to be
able to transfer the script onto another computer (which doesn't have
Ruby installed) and run the script. From what I've seen by playing with
it on my computer, it doesn't seem to be as simple as just copying the
".rb" file. But thanks a lot for the comment, I'll have to check out
that book you mentioned.

--
Posted via http://www.ruby-....

Martin DeMello

8/23/2008 5:26:00 AM

0

On Fri, Aug 22, 2008 at 10:21 PM, Todd Jacobus <raymondtjay@yahoo.com> wrote:
> Well that sounds like what I'm looking for. All I want to do is to be
> able to transfer the script onto another computer (which doesn't have
> Ruby installed) and run the script. From what I've seen by playing with
> it on my computer, it doesn't seem to be as simple as just copying the
> ".rb" file. But thanks a lot for the comment, I'll have to check out
> that book you mentioned.

http://www.erikveen.dds.nl/rubys...

Bundles the ruby interpreter and your script together into a
self-contained executable

martin

Daniel N

8/23/2008 5:47:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

On Sat, Aug 23, 2008 at 3:26 PM, Martin DeMello <martindemello@gmail.com>wrote:

> On Fri, Aug 22, 2008 at 10:21 PM, Todd Jacobus <raymondtjay@yahoo.com>
> wrote:
> > Well that sounds like what I'm looking for. All I want to do is to be
> > able to transfer the script onto another computer (which doesn't have
> > Ruby installed) and run the script. From what I've seen by playing with
> > it on my computer, it doesn't seem to be as simple as just copying the
> > ".rb" file. But thanks a lot for the comment, I'll have to check out
> > that book you mentioned.
>
> http://www.erikveen.dds.nl/rubys...
>
> Bundles the ruby interpreter and your script together into a
> self-contained executable
>
> martin


If it's just for a script on a *nix / mac machine then you can put this in
on the first line of the file.

#!/usr/bin/env ruby

then chmod it so that it's executable and put it into a directory that's
picked up in the PATH env variable. Then it'll be avaialble just like any
other command on your system.

Is this what you meant?

HTH
Daniel

Todd Jacobus

8/23/2008 6:04:00 AM

0

Awesome, that worked out great thanks!

--
Posted via http://www.ruby-....

matu

8/23/2008 7:35:00 AM

0

Daniel N wrote:

> #!/usr/bin/env ruby
>
> then chmod it so that it's executable and put it into a directory that's
> picked up in the PATH env variable.  Then it'll be avaialble just like any
> other command on your system.

this still needs the ruby interpreter.

Daniel N

8/23/2008 11:42:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

On Sat, Aug 23, 2008 at 5:31 PM, matu <m@t.u> wrote:

> Daniel N wrote:
>
> > #!/usr/bin/env ruby
> >
> > then chmod it so that it's executable and put it into a directory that's
> > picked up in the PATH env variable. Then it'll be avaialble just like
> any
> > other command on your system.
>
> this still needs the ruby interpreter.
>
>
Yes it does. But if your just after an executable that you can run on the
system without having to type ruby path/to/executable then this solution is
usually all that's needed

Cheers

Sebastian Hungerecker

8/23/2008 12:06:00 PM

0

Daniel N wrote:
> Yes it does. But if your just after an executable that you can run on the
> system without having to type ruby path/to/executable then this solution is
> usually all that's needed

Quoth the OP:
"All I want to do is to be able to transfer the script onto another
computer (which doesn't have Ruby installed) and run the script."
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

--
NP: Disbelief - For God
Jabber: sepp2k@jabber.org
ICQ: 205544826

Dave Bass

8/24/2008 9:03:00 PM

0

Sebastian Hungerecker wrote:
> Quoth the OP:
> "All I want to do is to be able to transfer the script onto another
> computer (which doesn't have Ruby installed) and run the script."
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Or maybe it does have Ruby installed, but an incompatible version
(1.8/1.9?). In the worst case the script may run without errors but do
something subtly different from what's intended.
--
Posted via http://www.ruby-....