【问题标题】:copy pscp a file from window server to to remote linux server将 pscp 文件从窗口服务器复制到远程 linux 服务器
【发布时间】:2014-05-18 03:27:37
【问题描述】:

我想将一个目录 (pscp) 从 windows 服务器复制到 Linux 服务器 Linux服务器上的目标地名每次都必须是新的。当我运行以下命令时,

> pscp -p -l root
> -pw mypassword -r C:\ProgramFiles\Mybackups\root@linux_server:/root/mywindowsbackups/$(date)

命令替换 $(date) 不起作用。 谁能建议我如何运行它?

【问题讨论】:

    标签: linux windows batch-file pscp


    【解决方案1】:

    尝试以下方法:

    :: This is stripping the `/` and `Day of the Week` from the date
    set target_date=%date:/=-%
    set target_date=%target_date:* =%
    
    :: Copying the directory to the linux server based on this system's date
    pscp -p -l root
    -pw mypassword -r C:\ProgramFiles\Mybackups\root@linux_server:/root/mywindowsbackups/%target_date%
    

    【讨论】:

    • 嘿,上面的代码有效,它正在使用当前日期在 linux 上创建目录,但它没有从源(windows)复制文件。我收到以下错误> pscp:无法打开 /home/ sudeep.m/05-18-2014:失败如果我指定一些随机名称,即使是这个错误也会出现。但是当我再次运行该命令时,它正在复制文件。
    • 嘿,如果我要自动执行此任务会怎样。就像我把这个命令放在 .bat 文件下,这个 .bat 文件每周从 Windows 任务调度程序运行一次 :)
    • 如果您的问题没有显示完整的任务,请编辑它并输入所有详细信息。
    猜你喜欢
    • 2019-01-20
    • 2010-09-09
    • 2011-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-07
    • 1970-01-01
    • 2013-08-23
    相关资源
    最近更新 更多