On Jul 5, 7:42 pm, Sam Smoot <ssm... / gmail.com> wrote: > On Jul 5, 10:28 pm, Chris Shea <cms... / gmail.com> wrote: > > > > > On Jul 5, 8:59 pm, SamSmoot<ssm... / gmail.com> wrote: > > > > Another nice way to do it would be to split it up into a Hash since > > > that would give you distinct option/value pairs. > > > > # s = "-A eth0-IN -i eth0 -s 192.168.0.0/24 -p tcp -m tcp --dport 22 - > > > j ACCEPT" > > > # => "-A eth0-IN -i eth0 -s 192.168.0.0/24 -p tcp -m tcp --dport 22 -j > > > ACCEPT" > > > # Hash[s.split] > > > # => {"-m"=>"tcp", "-p"=>"tcp", "-s"=>"192.168.0.0/24", "-i"=>"eth0", > > > "-j"=>"ACCEPT", "--dport"=>"22", "-A"=>"eth0-IN"} > > > Don't you need to splat the split? > > > mvb:~ cms$ ruby -v > > ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.9.1] > > mvb:~ cms$ irb > > irb(main):001:0> s = "-A eth0-IN -i eth0 -s 192.168.0.0/24 -p tcp -m > > tcp --dport 22 -j ACCEPT" > > => "-A eth0-IN -i eth0 -s 192.168.0.0/24 -p tcp -m tcp --dport 22 -j > > ACCEPT" > > irb(main):002:0> Hash[s.split] > > ArgumentError: odd number of arguments for Hash > > from (irb):2:in `[]' > > from (irb):2 > > from :0 > > irb(main):003:0> Hash[*s.split] > > => {"-m"=>"tcp", "-p"=>"tcp", "-s"=>"192.168.0.0/24", "-i"=>"eth0", "- > > j"=>"ACCEPT", "--dport"=>"22", "-A"=>"eth0-IN"} > > Yeah, I'm sorry. Got sloppy with my copy & paste and figured I could > just write it faster I guess. :) Although this doesn't account for a typo like leaving off some part of the pairs...could rescue for that situation. Thanks for all the feeback.