1

I have seen many people talk about copying a file from a remote server to their local drive but I would like to copy a file from the remote server to another folder on the remote server or to my shared drive.

I am trying to develop a Python GUI to migrate databases in Windows and I would like to be able to copy some of the databases to different locations.

I have tried shutil, xcopy and scp but none of these work. I always get errors like the "path does not exist" or "invalid drive specification".

Basically, I connect to the remote server using pyodbc in the following form:

connection = pyodbc.connect("DRIVER={SQL Server Native Client 10.0};SERVER=@servername;DATABASE=stage;UID=@myuserid;Trusted_Connection=yes").  

Once I have connected to server I define the two file paths as variables and then I call the xcopy function:

os.system ("""xcopy "%s" "%s" """ % (copy_path, paste_path)). 

Of course I do all of this after importing pyodbc, os, and sys libraries into python. The file does not copy whether I try to paste to a folder on the same server I connect to or my shared drive.

The xcopy only works when I try to copy files from my local to a remote server or vice versa. What I want to know is whether it is possible to copy a file from one spot on my remote server to another using Python.

For example if I remote connect to my remote server and run an xcopy on the following path on the server xcopy "F:\backup\dev\audit.bak" "F:\backup\test" I get the error "invalid drive specification 0 Files copied". I look at the directory tree but the moment I try a backup or a copy it gives me an error.

  • In it's current form, this is hard to answer - there could be a thousand reasons why it's not working. Maybe you could edit some details about your configuration into your post? – S.L. Barth is on codidact.com Feb 24 '14 at 14:58
  • The xcopy only works when I try to copy files from my local to a remote server or vice versa. What I want to know is whether it is possible to copy a file from one spot on my remote server to another using python. –  Feb 24 '14 at 18:26
  • I have edited your comments into the question. If you want to change some more (or undo my changes) you can use the "edit" button below the post. Since your errors are "path does not exist", I have a hunch the problem is your network setup, not your code. It might help if we know the precise line where the error occurs, and the values your variables have at that point. – S.L. Barth is on codidact.com Feb 25 '14 at 08:14

0 Answers0