In my Ruby scripting, there is probably no greater and chronic source of
irritation than way it copies files (something I do all the time). Most
of the time, I just fall back on a system command like `cp file1 file2`
because Fileutils.cp is so intransigent about syntax.
My problem is this. The script users enter a file name and a pathway as
follows:
pathName = "some_pathway"
fileName = "some_filename"
I simply want to copy that file to another directory. What syntax do I
need for Fileutils to copy the blasted file and quit issuing a billion
exceptions?
Intuitively, I'd say this should work:
Fileutils.cp( some_pathway+'/fileName', destDir )
Nope, it doesn't like fileName. OK, I'll protect it:
Fileutils.cp( some_pathway+'/#{fileName}', destDir )
Nope. OK, then:
Fileutils.cp( some_pathway+'/"#{fileName}'", destDir )
Nope.
(Try this another 50 ways, having it fail every time).
What am I doing wrong? Ruby is almost universally intuitive, but this
is one situation that makes me pull my hair out...
···
--
Posted via http://www.ruby-forum.com/.