I have written a python script that uses subprocess to call robocopy to sync log files from a remote host.
Like so:
program = 'Robocopy'
options = ['/S']
args.append(program)
args.append(options)
args.append('\\\\%s\%s' % (hostname, source_path))
args.append(local_path)
proc = subprocess.Popen(args=args, shell=True, stdout=cmd_log, stderr=error_log)
where source_path is the path on the remote host and local_path is the path on local host (both UNC paths). The code typically runs in a daemon process and gets kicked off every few hours. It is also possible to runs this code directly on the command prompt. It appears that sometimes when it is running in a daemon process I get an error from Robocopy:
Error code 6: 'The handle is invalid'
But when I run this on the command prompt I get no errors. From what I found in a web search this may be related to file handles that are already open on the files being transferred. Does anyone have more information on this error and ways to avoid it?