<div>Hi,</div>
<div> </div>
<div>I have used the following code snippet to copy files or folder from remote machine to local machine.</div>
<div>I have used the same method to copy files to remote machine.</div>
<div> </div>
<div>Can some one point me to solve this?</div>
<div> </div>
<div>Or </div>
<div> </div>
<div>Help needed to copy files or folders from remote machne ot lcoal one and also remote to remote copy if possible.</div>
<div> </div>
<div>thanks</div>
<div>Siddhartha</div>
<div> </div>
<div>--------------------------------------------------------------------</div>
<div>def netToLocalCopy(hostName, userName, password, source, destPath, move=False):<br> "Copies files or directories from a remote computer to local machine."<br> #Establish the connection to remote machine<br>
wnet_connect(hostName, userName, password)<br> # Get the UNC Path of the Destination Path<br> src_dir = convert_unc(hostName, source)<br> # Pad a backslash to the destination directory if not provided.<br> if not destPath[len(destPath) - 1] == '\\':<br>
destPath = ''.join([destPath, '\\'])<br> mesg = "Copying %s to %s Destination Directory on local host" % (src_dir, destPath)<br> print mesg<br> <br> # Create the destination dir if its not there.<br>
if not os.path.exists(destPath):<br> os.makedirs(destPath)<br> else:<br> # Create a directory anyway if file exists so as to raise an error.<br> if not os.path.isdir(destPath):<br> os.makedirs(destPath)<br>
print os.listdir(src_dir)<br> try:<br> if move:<br> shutil.move(src_dir, destPath)<br> else:<br> shutil.copy(src_dir, destPath)<br> except OSError, erno:<br> print erno<br>
print sys.exc_info()<br> return 1<br> return 0<br>-------------------------------------------------------------------------------------------------------</div>
<div> </div>
<div> shutil.copy(src_dir, destPath)<br> File "C:\Python25\lib\shutil.py", line 80, in copy<br> copyfile(src, dst)<br> File "C:\Python25\lib\shutil.py", line 46, in copyfile<br> fsrc = open(src, 'rb')<br>
IOError: [Errno 13] Permission denied: '\\\\test7\\G$\\Test Lib'</div>