copy , using 'system' 
Author Message
 copy , using 'system'

Quote:
>>>>> "Barry" == HP-Israel,ex1  <SHULTZ> writes:

    Barry> Hello, I've just been using Ruby for a few days, so please
    Barry> bear with me.  I want to copy a file using the 'system'
    Barry> function. I am running Win NT4, SP5 and have tried:

    Barry> system 'copy file newfile'
    Barry> system 'cp file newfile'
    Barry> system "copy file newfile"
    Barry> system "cp file newfile"

    Barry> The copy is never performed, and the value of $? is 32512.
    Barry> Any help would be appreciated.

I would guess that you have to use something like:

  system 'cmd /c copy file newfile'

as 'copy' is not an external but an internal command of the command
interpreter 'cmd.exe'.

But you could also do it like that:

  require 'ftools'
  File::copy 'file', 'newfile'

That should be more portable than you trial with 'copy'.

    Barry> Regards, Barry

HTH,
\cle



Sat, 24 May 2003 03:00:00 GMT  
 copy , using 'system'
Hello,
 I've just been using Ruby for a few days, so please bear with me.
I want to copy a file using the 'system' function. I am running
Win NT4, SP5 and have tried:

system 'copy file newfile'
system 'cp file newfile'
system "copy file newfile"
system "cp file newfile"

The copy is never performed, and the value of $? is 32512.
Any help would be appreciated.

Regards,
Barry



Sat, 24 May 2003 23:26:18 GMT  
 copy , using 'system'
try these:
        system("cp","file","newfile")
        OR
        system("copy","file","newfile")
        OR JUST
        `copy file newfile`

It sounds like your REALLY want to use system, but a better way might
be to use the ftools library like this.

require 'ftools'

File.copy 'file', 'newfile'

Dave Thomas wrote a very good book on the language that you can buy.
You can see it at his website,
http://www.pragmaticprogrammer.com/ruby/index.html

Good luck,
/<

Quote:

> Hello,
>  I've just been using Ruby for a few days, so please bear with me.
> I want to copy a file using the 'system' function. I am running
> Win NT4, SP5 and have tried:

> system 'copy file newfile'
> system 'cp file newfile'
> system "copy file newfile"
> system "cp file newfile"

> The copy is never performed, and the value of $? is 32512.
> Any help would be appreciated.

> Regards,
> Barry



Sun, 25 May 2003 02:27:46 GMT  
 copy , using 'system'
Thanks for the help, Keith. I really did _not_ want to use 'system', but
when I didn't find a 'copy' method
in the standard File class, I thought I should try the ugly way. Maybe I
should buy the book.

Barry

Quote:
-----Original Message-----

Sent: Tuesday, December 05, 2000 8:28 PM

Subject: [ruby-talk:6821] Re: copy , using 'system'

try these:
        system("cp","file","newfile")
        OR
        system("copy","file","newfile")
        OR JUST
        `copy file newfile`

It sounds like your REALLY want to use system, but a better way might
be to use the ftools library like this.

require 'ftools'

File.copy 'file', 'newfile'

Dave Thomas wrote a very good book on the language that you can buy.
You can see it at his website,
http://www.pragmaticprogrammer.com/ruby/index.html

Good luck,
/<


> Hello,
>  I've just been using Ruby for a few days, so please bear with me.
> I want to copy a file using the 'system' function. I am running
> Win NT4, SP5 and have tried:

> system 'copy file newfile'
> system 'cp file newfile'
> system "copy file newfile"
> system "cp file newfile"

> The copy is never performed, and the value of $? is 32512.
> Any help would be appreciated.

> Regards,
> Barry



Sun, 25 May 2003 03:39:43 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. using 'system' under win2000/nt/9x

2. changing the shell used by 'system'

3. Copy files using AWK's output

4. Copy 'DOS' File to another directory

5. 'COPY TO' command

6. Do we need 'copy'?

7. System abend '0E37'?

8. 'SOOP' Class system

9. Computer System 'HOLY WATER'

10. a Perl script's interaction with Ruby's system call

11. system('dir') and Windows 2000

12. R'n'R Ada and embedded systems

 

 
Powered by phpBB® Forum Software