noob question

D

Dirk Meijer

------=_Part_14526_21351915.1127712327658
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

this may be a stupid question, and i might have even overlooked it in the
pickaxe, but what code do i need to insert in my program so it takes
parameters passed by the shell as variables?
greetings, Dirk.

------=_Part_14526_21351915.1127712327658--
 
B

Brian Mitchell

this may be a stupid question, and i might have even overlooked it in the
pickaxe, but what code do i need to insert in my program so it takes
parameters passed by the shell as variables?
greetings, Dirk.

ARGV are the parameters. $0 is the program name.

ARGF is another odd tool for some tasks. I recommend avoiding it
unless it is for simple scripts.

Brian.
 
L

luke

parameters passed in through the shell can be grabbed through the global
array ARGV

so .. for example, if in the shell i were to type:

% ruby crawl.rb July 2005

"July" would be ARGV[0]
and "2005" would be ARGV[1]

luke

ps) i'm a n00b too, so as far as i know this is right :> works for me with
ssh anyway.



this may be a stupid question, and i might have even overlooked it in the
pickaxe, but what code do i need to insert in my program so it takes
parameters passed by the shell as variables?
greetings, Dirk.
 
D

Doug Kearns

On Mon, Sep 26, 2005 at 02:32:15PM +0900, Brian Mitchell wrote:

ARGF is another odd tool for some tasks.

That strikes me as a peculiar statement.
I recommend avoiding it unless it is for simple scripts.

Why?

Regards,
Doug
 
J

James Edward Gray II

ARGF is another odd tool for some tasks. I recommend avoiding it
unless it is for simple scripts.

I'm not sure why you say this.

ARGF is a tool for building Unix style filters. If you believe
filters are the way to go in data processing, as I do, you use it all
the time.

James Edward Gray II
 
B

Brian Mitchell

I'm not sure why you say this.

ARGF is a tool for building Unix style filters. If you believe
filters are the way to go in data processing, as I do, you use it all
the time.

James Edward Gray II

To clarify the statement, it has multiple behaviors and can change the
semantics of the command line. Odd behavior that happens to fit
naturally with data filters. I guess it depends on how you look at it.

I tend to avoid it like I said, as I like to be more explicit about my
how I treat my parameters. Again, I should have noted that it was more
opinion than hard fact. Sorry for the lazy posting. :)

Brian.
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top