X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f From: "MikeC" Newsgroups: comp.os.msdos.djgpp References: Subject: Re: How to copy a file? Lines: 66 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138 Message-ID: Date: Sat, 29 Sep 2007 16:00:11 GMT NNTP-Posting-Host: 86.13.147.52 X-Complaints-To: http://netreport.virginmedia.com X-Trace: newsfe3-gui.ntli.net 1191081611 86.13.147.52 (Sat, 29 Sep 2007 17:00:11 BST) NNTP-Posting-Date: Sat, 29 Sep 2007 17:00:11 BST Organization: ntl Cablemodem News Service To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com wrote in message news:OF729DCA1D DOT 55951EA7-ON87257360 DOT 006A997C-87257360 DOT 006B1643 AT seagate DOT com... > "MikeC" wrote on Fri, 21 Sep 2007 00:31:07 GMT: > > # Why can't I do it with ... > # > # system(string); /* string contains "copy " */ > # > # ... as I tried? It compiles OK, and appears to execute when I > single-step > # the program under RHIDE, but it takes an instant - not a minute or > more - > > # and the file doesn't get copied. I don't know what I'm doing wrong. > > You can. As mentioned, there's no "copy" program - it's trying to > find "copy.exe" or "copy.com". > > That means there's two answers: > 1) Use XCOPY.EXE > 2) Invoke the command interpreter: > system("command.com /c copy ...."); > > The second can be a little tricky, because you have to know the name of > the command interpreter. Go with COMMAND.COM, even though that's not > what is usually used for a DOS box in 2K/XP. > Thanks a million, Gordon, How did you know that xcopy is an embedded command, and that copy is not? Where do I find this kind of information? As you say, the second option is tricky - in fact, I couldn't make it work, though I tried "command", "command /c" "cmd" and various other options - but xcopy certainly does it. In fact, the options given with xcopy (command-line switches) obviate a lot of what my program was trying to achive. It's a simpler program now. I would remark, however, that xcopy is not as fast as copy. It would have been nice to find a faster option - especially as I know that one exists (copy is faster), as now that the program has crossed the first hurdle of downloading one file, it will go on to spending three or four days downloading the entire directory with subdirectories, and a few percentage points in speed would have made a difference. My program is effectively a backup program, so once it has downloaded the data, a weekly backup of the Colorado server directory will download only the files that are newer than the ones it already has, so it will go much quicker. The 'first' file in question is approx 10 meg on a server at my company HQ in Colorado. I connect from England through VPN. Working from a DOS box under Win2K.... With copy, it takes 1min 13 secs to download. With xcopy, it takes 1min 31. In my program, executing the system call to xcopy also takes 1min 31 secs, which is faster than the function I wrote, using 64K buffers, though I never got around to trying Mr Delorie's suggestion of using read/write instead of fread/fwrite to speed it up, as I've been away for a week, and just got back to the project today. Once again, my thanks to all who responded. MikeC.