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);
}
}
}
Re: Xcopy between two servers
The first system call needs a few more '\' s.
You did it right in the second system call.
Kurt
Re: Xcopy between two servers
Are you sure you can copy it from server to server ?
XCopy info
Quote:
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.
Re: Xcopy between two servers
Quote:
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
Re: Xcopy between two servers
Quote:
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?
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... :cry:
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
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...
Re: Xcopy between two servers
Sorry for disappointing you guys... :D
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
Re: Xcopy between two servers
When I got my fingers badly burned I was running XP so I guess you run Win7?
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. ;)
Re: Xcopy between two servers
There's always something new to learn... :)
Thanks!
Re: Xcopy between two servers
Thanks for the tip! It saved my life :)