Score:0

Powershell Cygwin copy data with Rsync remote as variable

cn flag

I have a problem with Cygwine's rsync. With a Powershell script I am trying to transfer directories from a Novell server to a Windows server

The path for the source is a variable that comes from a CSV file

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

If the source path in the variable does not contain a white space the script runs correctly, but if the path contains a white space the content of the variable will be parsed with quotes and the script stop running because the SSH session recieve "root@... as user with quotes in the begining of user root like this

"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

How can I parse a variable to ignore the quote from script variable?

Score:0
cn flag

I use Visual Studio Code and the code work well. I think the ISE IDE of Powershell not interpreting quotes correctly

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.