From: mail02@... (Frank Benoit) Date: 2002-01-02T09:25:08+09:00 Subject: [ruby-talk:29999] Re: Execing command with backquotes On Tue, 01 Jan 2002 23:32:43 GMT, "Mark Hahn" wrote: >You need to add cmd.exe like this: > >cmd = "cmd.exe /c xcopy /s /e c:\\A\\*.* c:\\B" > >Test things first with something simple like DIR. > >-----Original Message----- >From: Frank Benoit [mailto:mail02@frankbenoit.de] >Sent: Tuesday, January 01, 2002 1:25 PM >To: ruby-talk ML; undisclosed-recipients: >Subject: [ruby-talk:29991] Execing command with backquotes > > >Hi > >I tried to do something like > >cmd = "xcopy /s /e c:\\A\\*.* c:\\B" >msg = `cmd` >..... > >But the programm hangs. After pressing Control-C 2 times Windows says: > >A process tries to write onto a not existing pipe. (I tried to >translate this, not the original message) > >Thx for help > I tried this: sourcedir = "c:\\temp\\from\\" targetdir = "c:\\temp\\into\\" commandstring = "xcopy /s /e #{sourcedir}*.* #{targetdir}" #commandstring = "cmd.exe /c xcopy /s /e #{sourcedir}*.* #{targetdir}" # commandstring = "cmd.exe /c \"xcopy /s /e #{sourcedir}*.* #{targetdir}\"" puts commandstring # Execute print "Excecute : >" returnval = `#{commandstring}` puts "<" # Print Commandoutput puts "Returnvalue: >" + returnval + "<" Here is the output: xcopy /s /e c:\temp\from\*.* c:\temp\into\ Excecute : >< Returnvalue: >< But still there is nothing copied. When I try the command xcopy /s /e c:\temp\from\*.* c:\temp\into\ into console, it works fine.