Powershell Cygwin은 Rsync 원격을 변수로 사용하여 데이터를 복사합니다.

Powershell Cygwin은 Rsync 원격을 변수로 사용하여 데이터를 복사합니다.

Cygwine의 rsync에 문제가 있습니다. Powershell 스크립트를 사용하여 Novell 서버에서 Windows 서버로 디렉터리를 전송하려고 합니다.

소스 경로는 CSV 파일에서 가져온 변수입니다.

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@.dll"을 수신하므로 스크립트 실행이 중지됩니다. .. 사용자 루트의 시작 부분에 따옴표가 있는 사용자로서 다음과 같이

"E:\cwRsync\bin\rsync.exe" -vrts --progress --whole-file --no-compress --no-checksum -e /cygdrive/e/CWrsync/bin/ssh "[email protected]:/media/nss/rep01/Com/Com dir Soins info/" /cygdrive/g/Shares/C:\temp\Rsync --delete-before

스크립트 변수의 인용문을 무시하기 위해 변수를 어떻게 구문 분석할 수 있나요?

답변1

Visual Studio Code를 사용하고 있는데 코드가 잘 작동합니다. Powershell의 ISE IDE가 따옴표를 올바르게 해석하지 못하는 것 같습니다.

관련 정보