From: Seth Kurtzberg Date: 2003-03-12T04:51:51+09:00 Subject: Re: when a ruby script gets arguments passed to it..... There is a library distributed with ruby to parse arguments. As an alternative, I have an argument parsing module which I will send to you if you like. I will release it generally when I've completed some documentation. For the one distributed with most linux distros there is a program in the ruby examples directory which uses it. In general, the best syntax (IMHO, of course) is the extract each argument from the input list using ARGV.shift. Other methods for accessing members of a string array can also be used. On Tuesday 11 March 2003 12:36 pm, Greg Banschbach wrote: > Dear All, > I was wondering what kinds of command line parsing I > can do. I mean, if I have a script foo.rb and I > type: > > ./foo -c "comment string" -t type -o option > > OR I type > > ./foo -c"comment string" -ttype -ooption > > in a "vanilla" ruby script, will it be like "vanilla" > bourne shell options ie: the -c would be the $1 > "comment string" would be $2.... and so on. > > What is the "vanilla" method, and what is the > "smarter" way to parse it. In the bourne shell, I can > use getopts but I can't handle if the person omits the > space between arguments [ perhaps I need a patch ]. > Anyway, I want to setup an environment and then run a > further command with arguments that I figured out. > ie > foo.rb -c "test comment" -d pgroup1 > > results in lp -t "test comment" -d printer2 > > or results in lp -t "test comment" -d fax1 > > based on other command line or environment. > > > Thanks very much in advance ! > > Greg > > __________________________________________________ > Do you Yahoo!? > Yahoo! Web Hosting - establish your business online > http://webhosting.yahoo.com -- Seth Kurtzberg M. I. S. Corp. 480-661-1849 seth@cql.com