【问题标题】:How to get files from Remote windows server to local Windows machine directory?如何从远程 Windows 服务器获取文件到本地 Windows 机器目录?
【发布时间】:2016-09-29 17:52:15
【问题描述】:

我正在使用一种工具,该工具将在远程 Windows 2012 服务器中连续创建文件。我需要获取这些文件并将其放在本地目录中。

import os
import time

def copy_logs():
    os.system(".\pscp.exe -pw test123 C:/Users/Administrator/Desktop/tr* Administrator@1.1.1.1:/")
    time.sleep(7200)    
while True:
    copy_logs()

我在 python 脚本中使用了“pscp”来复制文件。但我无法指定将文件复制到的空间/目标目录。

有没有办法用 Python 实现这一点?

【问题讨论】:

  • 请忘记 os.system 并用更强大的解决方案替换它,即:subprocess.check_call。
  • 目标目录是/:远程服务器的根目录(这是坏的)。远程路径应该这样指定:Administrator@1.1.1.1:/path/to/the/destination/directory/.
  • pscp 的文档可在此处获得:linux.die.net/man/1/pscp

标签: python python-2.7


【解决方案1】:

我知道的最佳解决方案是使用Fabric。见:How do I copy a directory to a remote machine using Fabric?。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多