[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

FileUtils.cp_r

Marc Heiler

7/18/2008 8:37:00 PM

Hi,

I have all of the program "atk" in one directory.

I want to recursively copy this to /usr.

This commandline works in bash shell:

cp -r /Programs/Atk/Current/* /usr/

These examples in Ruby do not work:

FileUtils.cp_r '/Programs/ATK/Current/', '/usr'
FileUtils.cp_r '/Programs/ATK/Current/', '/usr/'
FileUtils.cp_r '/Programs/ATK/Current', '/usr/'

(They all copy Current/ instead of what is inside Current/* )

And using '*' like so

FileUtils.cp_r '/Programs/ATK/Current/*', '/usr/'

does neither work.

Does anyone have an idea how to grab the * content
under Current/ and copy that to /usr ?
--
Posted via http://www.ruby-....

6 Answers

Marc Heiler

7/18/2008 8:41:00 PM

0

I was able to solve it with a 4 year old post of Nobu :)

One has to add the '/.'

I think the docu could mention this:

FileUtils.cp_r( '/Programs/ATK/Current/'+"/.", '/usr/')


Works.
--
Posted via http://www.ruby-....

matt

7/19/2008 4:24:00 AM

0

Marc Heiler <shevegen@linuxmail.org> wrote:

> I was able to solve it with a 4 year old post of Nobu :)
>
> One has to add the '/.'
>
> I think the docu could mention this:

The docs *do* say exactly that, I think:

> # If you want to copy all contents of a directory instead of the
> # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
> # use following code.
> FileUtils.cp_r 'src/.', 'dest'

m.
--
matt neuburg, phd = matt@tidbits.com, http://www.tidbits...
Leopard - http://www.takecontrolbooks.com/leopard-custom...
AppleScript - http://www.amazon.com/gp/product/...
Read TidBITS! It's free and smart. http://www.t...

Ryan Davis

7/19/2008 6:31:00 PM

0


On Jul 18, 2008, at 13:40 , Marc Heiler wrote:

> I think the docu could mention this:
>
> FileUtils.cp_r( '/Programs/ATK/Current/'+"/.", '/usr/')


there is a whole well documented paragraph of code on it (two in fact,
if you count the glob one):

> ---------------------------------------------------------
> FileUtils#cp_r
> cp_r(src, dest, options = {})
> ------------------------------------------------------------------------
> Options: preserve noop verbose dereference_root
> remove_destination
>
> Copies +src+ to +dest+. If +src+ is a directory, this method
> copies
> all its contents recursively. If +dest+ is a directory, copies
> +src+ to +dest/src+.
>
> +src+ can be a list of files.
>
> # Installing ruby library "mylib" under the site_ruby
> FileUtils.rm_r site_ruby + '/mylib', :force
> FileUtils.cp_r 'lib/', site_ruby + '/mylib'
>
> # Examples of copying several files to target directory.
> FileUtils.cp_r %w(mail.rb field.rb debug/), site_ruby + '/
> tmail'
> FileUtils.cp_r Dir.glob('*.rb'), '/home/aamine/lib/
> ruby', :noop => true,
> :verbose => true
>
> # If you want to copy all contents of a directory instead of
> the
> # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
> # use following code.
> FileUtils.cp_r 'src/.', 'dest' # cp_r('src', 'dest')
> makes src/dest,
> # but this doesn't.



The Lord of Eltingville

6/4/2010 6:54:00 PM

0

Bill wrote:
> Lindsay snorts rocks!


There. FTFY...

james.pablos

6/4/2010 10:00:00 PM

0

On Jun 3, 10:40 pm, "octoad" <davk...@sonic.net> wrote:

> That's my girl!
>

Golden showers?

iL_weReo

6/4/2010 10:37:00 PM

0

In article
<2fc8c9bc-dbcf-4bdc-a7f6-452d533c57b5@u7g2000vbq.googlegroups.com>,
James Pablos <james.pablos@gmail.com> wrote:

> On Jun 3, 10:40?pm, "octoad" <davk...@sonic.net> wrote:
>
> > That's my girl!
> >
>
> Golden showers?

Figures that u'd like them LIEshine tricks
--
PiGGy PiGGy...ass so FAT
OH MY GOD how u?d ever get as UGLY as THAT?

PEDOTARD PIG FACE SHITSHINE the CIRCUS PIG
& WORTHLESS DELUSIONAL LYING PATHETIC PATHOLOGICAL
PERVERT?d FAT STUPID ReTARD?d RABID PEDOPHILE WARTHOG says WHAT???