首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >以Rsync remote为变量的Powershell Cygwin复制数据

以Rsync remote为变量的Powershell Cygwin复制数据
EN

Server Fault用户
提问于 2022-04-27 15:59:39
回答 1查看 245关注 0票数 0

我对塞格葡萄酒的rsync有意见。使用Powershell脚本,我试图将目录从Novell服务器传输到Windows服务器

源的路径是来自CSV文件的变量。

代码语言:javascript
复制
Function CopyRsync ([string]$source,[string]$dest){   
        $sourceRoot = "root@"+$source +"/"        
        $dest = "/cygdrive/g/Shares/" +$dest

cmd.exe /C "e:\cwRsync\bin\rsync.exe" -vrts --progress --whole-file --no-compress --no-checksum  -e "/cygdrive/e/CWrsync/bin/ssh" $sourceRoot $dest --delete-before         
    }

$novel = 'server.domaine.local:/media/nss/rep01/Com/Com dir Soins info'
$dfs = "C:\temp\Rsync"
CopyRsync -source $novel -dest $dfs

如果变量中的源路径不包含空白,则脚本正确运行,但如果路径包含空白,则变量的内容将被引号解析,脚本将停止运行,因为SSH会话接收“root @.为用户在用户根的起始处引用引号,如下所示

代码语言:javascript
复制
"E:\cwRsync\bin\rsync.exe" -vrts --progress --whole-file --no-compress --no-checksum -e /cygdrive/e/CWrsync/bin/ssh "root@server.domaine.local:/media/nss/rep01/Com/Com dir Soins info/" /cygdrive/g/Shares/C:\temp\Rsync --delete-before

如何解析变量以忽略脚本变量的引号?

EN

回答 1

Server Fault用户

回答已采纳

发布于 2022-05-05 13:50:22

我使用代码,代码运行良好。我认为Powershell的ISE IDE没有正确解释引号

票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/1099614

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档