On Wed, 19 Feb 2003 16:30:30 +0900 "Useko Netsumi" <usenets / nyc.rr.com> wrote: > Thank you, but its a bit advance for me. I'd like to start on how to parse > arguments from a shell scripts such as the following: > > usage: mktmpswap -c c0 -b b0 -f f0 > > Using Bourne shell, I can use case statement and awk to parse each argument > and capture its value ... > > if -c then set count = c0 > if -b then set blocksize = b0 > if -f then set filename = 0 > > I'd love to get some simple example to do the above. Thanks. > This is just off the top of my head, I'm sure there's better ways: #!/usr/bin/env ruby count = nil f = nil ARGV.each_with_index{ |x, i| case x when '-c' count = ARGV[i+1] when '-f' f = ARGV[i+1] end } puts count puts f > > > "Gavin Sinclair" <gsinclair / soyabean.com.au> wrote in message > news:127599967147.20030219172252 / soyabean.com.au... > > On Wednesday, February 19, 2003, 5:10:15 PM, Useko wrote: > > > > > Hi, I'm a newbie looking for any example of writing ruby script to do my > > > daily sysadmin chores. If anyone here knows their existence, please > forward > > > me with the link. Thanks a bunch. > > > > > > Take a look at > > > > http://www.rubygarden.org/ruby?SysAdmin > > > > Please post suggestions for others. People will happily write some > > good ones and add them to the collection. > > > > Gavin > > > > > > -- Daniel P. Zepeda