Modify remote winodws server filesystems

  filesystems, python, windows

windows to windows error!
i should scan the filesystems on one remote server and judge every file does it exists on another windows server, and modify the file, such like detele and write it..
there is a problem when i modify on the remote server,i think it’s the lack of authority.
but how could i increase the authrioty. thanks

python3.x

    host_138 = '192.168.x.xx'
    host_90 = '192.168.x.xxx'
    logger = LOG(__name__, '', logger_type='stram').logger

    def make_root_path(host_str):
        return rf'{host_str}外刊全文'

    root_path = make_root_path(host_138)
    for idx, f in enumerate(os.walk(root_path)):
        if idx == 0:
            continue
        for filename in f[2]:
            if filename.endswith('pdf'):
                path = os.path.join(f[0], filename)
                target_path = path.replace(host_138, host_90)
                if os.path.exists(target_path):
                    os.remove(path)
                    # shutil.rmtree(path)
                    logger.info(f"DELETE info {path}")
                else:
                    with open(target_path, 'wb') as wf:
                        with open(path, 'rb') as rf:
                            wf.write(rf.read())
                    logger.info(f"ADD file {target_path}")

ERROR:
Traceback (most recent call last):
File "E:/JHProjects/juhe/JH/DataCenter/check_work/check.py", line 201, in
check_file()
File "E:/JHProjects/juhe/JH/DataCenter/check_work/check.py", line 154, in check_file
os.remove(path)
PermissionError: [WinError 5] 拒绝访问。: ‘192.168.x.xxx外刊全文0941-0768MCT-1461669.pdf’

Source: Windows Questions

LEAVE A COMMENT