From: Dan Q Date: 2009-11-20T05:56:19+09:00 Subject: Re: For Loop I would add that you can use backticks to execute a shell command, as follows: `scp "#{group}" user@server1:/tmp` I would suggest reading some Ruby tutorials online, because it's pretty different from Bash, and you often won't want to just translate things literally. Learning one's second programming language is a big deal :-) -Dan On Thu, Nov 19, 2009 at 2:52 PM, Mike Stok wrote: > > 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. > > > > > >