From: Mike Stok Date: 2009-11-20T05:52:43+09:00 Subject: Re: For Loop On Nov 19, 2009, at 3:38 PM, Gilberto Gilberto wrote: > Hello All, > > I am starting to experiment with Ruby for Sys Admin tasks. Now, I have > been working with Shell scripting for a few years now. Currently, I am > trying to figure out how I can create a "for loop" in Ruby. > > In bash, I have the following: (the following is what I would like to > translate in Ruby but can't seem to figure this out) > > BASH - here, I am trying to copy a few files to the same server in one > shot > > for groups in "Account File" \ > "Bank File" \ > "Study Case" \ > "Overall Status" ; > do > scp $groups user@server1:/tmp > done > > > For Ruby, I tried - > > for group in Account File", > "Bank File", > "Study Case", > "Overall Status" > do > (scp groups user@server1:/tmp) > end > > Of course, I get syntax errors everywhere. I am not sure how to use a > for loop in this case. Any input? [ "Account File", "Bank File", "Study Case", "Overall Status" ].each do |group| puts "processing #{group}" end Hope this helps, Mike -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply.