From: Gennady Date: 2003-03-12T04:48:55+09:00 Subject: Re: when a ruby script gets arguments passed to it..... Global aray ARGV -- contains command line parameters. GetoptLong -- parses options, a.l.a shell's getopts, but better (search http://www.ruby-doc.org/docs/ProgrammingRuby/html/lib_standard.html for GetoptLong description) Gennady. ----- Original Message ----- From: "Greg Banschbach" To: "ruby-talk ML" Sent: Tuesday, March 11, 2003 11:36 AM Subject: when a ruby script gets arguments passed to it..... > 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 > >