-
May 3rd, 2012, 07:09 AM
#1
Xcopy between two servers
Hi everyone, I am trying to move files from one folder (server 1) to another folder(server 2) through command xcopy . I am using the editor dev c++. My code works fine if i have to move file within single server but gives error " Invalid parameters " if i am trying between servers.
Here is the code
int main(int argc, char *argv[]) {
time_t start, stop;
clock_t ticks; long count;
time(&start);
int i=0;
while(1)
{
time(&stop);
if(difftime(stop, start)== 60) // moving file after every one min
{
//abc is my folder and have to move to test folder of another server
//have replaced server name wid server 1 and 2
system("xcopy server1\C:\abc server2\share\C:\test /e/v/s/f/q");
system("del c:\\abc /s");
time(&start);
}
}
}
-
May 3rd, 2012, 07:20 AM
#2
Re: Xcopy between two servers
The first system call needs a few more '\' s.
You did it right in the second system call.
Kurt
-
May 3rd, 2012, 08:07 AM
#3
Re: Xcopy between two servers
Are you sure you can copy it from server to server ?
XCopy info
Destination : Specifies the destination of the files you want to copy. This parameter can include a drive letter and colon, a directory name, a file name, or a combination of these.
It doesn't state that you can copy it from server to server. Only from drive to drive.
-
May 3rd, 2012, 08:48 AM
#4
Re: Xcopy between two servers
Originally Posted by Skizmo
Are you sure you can copy it from server to server ?
I think you can but you have to use shares like
Code:
system("xcopy \\\\server1\\C$\\abc C:\\test /e/v/s/f/q");
to copy from server1 to a local directory
Kurt
-
May 3rd, 2012, 10:05 AM
#5
Re: Xcopy between two servers
Originally Posted by jha.prakash24
Hi everyone, I am trying to move files from one folder (server 1) to another folder(server 2) through command xcopy .
Did you consider using SHFileOperation instead?
Victor Nijegorodov
-
May 3rd, 2012, 02:58 PM
#6
Re: Xcopy between two servers
I doubt that any console command is capable of handling network paths that aren't mapped to a drive letter.
I've had some really bad side-effect from trying to run a .bat file when I wasn't on a mapped network path. The shell defaulted to open in the c:\windows, I was running as admin and the bat file contained del /S *.exe. Well you might guess the result...
-
May 3rd, 2012, 03:10 PM
#7
Re: Xcopy between two servers
I'm quite shure that i did it in VB script before.
But I agree that such an experience is a good reason to use SHFileOperation.
Kurt
-
May 3rd, 2012, 04:50 PM
#8
Re: Xcopy between two servers
I do use xcopy within a .bat file sucessfully...
EDIT:
OR you can do as Igor suggest in the next post...
BUT
also agree with VictorN...I find SHFileOperation easier to use within C++ than a "system" call plus you can also get a progress bar for the file operation. Give SHFileOperation a try...if you need help just give a shout for a sample...
HTH...
Last edited by Vanaj; May 4th, 2012 at 12:48 AM.
Reason: tech...
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
-
May 4th, 2012, 12:44 AM
#9
Re: Xcopy between two servers
Sorry for disappointing you guys...
Code:
D:\>xcopy \\SERVER\exchange\Vartanov\*.jpg \\DDBUILDER\e$\1\*
\\SERVER\exchange\Vartanov\05.12_Вартанов2 001.jpg
\\SERVER\exchange\Vartanov\05.12_Вартанов1 001.jpg
2 File(s) copied
Best regards,
Igor
-
May 4th, 2012, 11:13 AM
#10
Re: Xcopy between two servers
When I got my fingers badly burned I was running XP so I guess you run Win7?
-
May 4th, 2012, 10:40 PM
#11
Re: Xcopy between two servers
Nope. It's Windows XP SP3, and you take my word I did this even back in Windows NT4 ages.
The real difference between the cases, mine and yours, is that mine has paths fully specified while yours might rely on current directory. The latter really must be set to some letter drive based path, otherwise it's %WINDIR%\system32 that automatically implied.
Best regards,
Igor
-
May 5th, 2012, 04:32 AM
#12
Re: Xcopy between two servers
There's always something new to learn...
Thanks!
-
December 26th, 2012, 04:44 PM
#13
Re: Xcopy between two servers
Thanks for the tip! It saved my life
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|