Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Set-SCPItem for a directory does not support unregular characters #535

Open
Klaboe opened this issue Jul 9, 2023 · 7 comments
Open

Set-SCPItem for a directory does not support unregular characters #535

Klaboe opened this issue Jul 9, 2023 · 7 comments

Comments

@Klaboe
Copy link

Klaboe commented Jul 9, 2023

Trying to send a whole directory using Set-SCPItem that contains unregluar characters in its name leads to what seems like a locked terminal and nothing happens. I haven't investigated this deeply (maybe the same goes for regular files as well) but a command like this:

>> Set-SCPItem -ComputerName computername -Path .\Folder(Name)\ -Destination /Upload/ -Verbose

VERBOSE: Using SSH Username and Password authentication for connection.
VERBOSE: ssh-ed25519 Fingerprint for computername: <...mac-adress-or-something>
VERBOSE: Fingerprint matched trusted ssh-ed25519 fingerprint for host computername
VERBOSE: Connection successful
VERBOSE: Uploading: C:\Users\User\Folder(Name)\
VERBOSE: Destination: /MUSIC/Interplay/Folder(Name)

This will just hang forever (at least over night 😅) and cant be interupted with ctrl+c. I'm gussing it has to do with some path-parsing on the destination side as ( needs to be escaped 🤔 ( on a *unix machine

As a sidenote; if one tries to send a directory, and a directory with the same name doesn't exist on the Destination, one would get a

>> Set-SCPItem -ComputerName computername -Path .\SomeDir\ -Destination /Upload/ -Verbose
(...)
Set-SCPItem: scp: /Upload/SomeDir: No such file or directory

Which is a little counter-intuitive when one tries to send a complete directory, but not a huge problem. Just annoyance 😇

 >>  Get-Module Posh-SSH

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Manifest   3.0.8                 Posh-SSH                            {Get-SCPItem, Get-SFTPItem, Get-SSHHostKey, Get-SSHJsonKnownHost…}`
@MVKozlov
Copy link
Contributor

you may try to use -PathTransformation parameter

@Klaboe
Copy link
Author

Klaboe commented Jul 12, 2023

For which part? The sending of directory with unregular characters, or the handling of "no such file or directory"?

(Both?)

@MVKozlov
Copy link
Contributor

the single command you use in your example - Set-SCPItem :)

@bero20007
Copy link

I still have this problem and not fix it yet, and I'm trying tying to use Set-SCPItem with for loop to looping on each file on my folder and then copy it into my server.

$files = Get-ChildItem -Path $MyPath -File
foreach ($file in $files) {
    $src = Join-Path -Path $MyPath -ChildPath $file.Name

    Set-SCPItem -ComputerName $ComputerName -Credential $Credentials -path $src -Destination $Destination -Verbose
}

@darkoperator
Copy link
Owner

darkoperator commented Apr 15, 2024 via email

@bero20007
Copy link

What special characters are in your case causing it to fail?

$ComputerName = "MYSERVERIP"
$MyPath = "C:\Users\ibrahim\Desktop\ProjectPublish"
$Destination = "/var/www/Project/API"
Set-SCPItem -ComputerName $ComputerName -Credential $Credentials -path $MyPath -Destination $Destination -Verbose

the connection and handshake work well but the upload start:
VERBOSE: Uploading: C:\Users\ibrahim\ProjectPublish
VERBOSE: Destination: /var/www/Project/API/ProjectPublish
and that's wrong because ProjectPublish is not exist on my server it's a folder i use to store my project publish result on my device
what i want is to copy all files inside ProjectPublish folder into this path: /var/www/Project/API/ on my server
the conclusion is why my local folder ProjectPublish concat with the Destination and became like this: /var/www/Project/API/ProjectPublish

@darkoperator
Copy link
Owner

darkoperator commented Apr 15, 2024 via email

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants