-
Notifications
You must be signed in to change notification settings - Fork 138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remote path containing backslash not matched on Windows server when using scp.SCPClient.get from Linux client #138
Comments
I'm not sure I understand the slash issue, does opening "V:/test.txt" not work on Windows, same as "V:\test.txt"? Escaping spaces was implemented (#9) and is tested for, so if you're seeing problems there it might be another Windows-specific problem? |
I've just realized that scp expects you to use "/" as the path separator even when copying from a Windows machine. So get("V:/test.txt") does work, whereas get("V:\test.txt") does not and gives the misleading error that 'V:/test.txt' doesn't exist. As for spaces, if I'm trying to copy "V:\test 1.txt", I've tried:
There is clearly something weird going on with the formatting of the output message, though that may be a separate issue to whether escaping works. |
The second version is expected to work ( Also all of this might depend on your server implementation (if using cygwin, you might need |
Pardon my inconsistency with filename above. That aside, I am sure the file exists. For comparison I can copy it without problem using paramiko.SFTPClient:
I also just discovered that quoting doesn't seem to be acceptable in the first place, with or without spaces in the filename.
|
I fear I know what is happening. Do you mind trying the following:
|
|
Ok well what is apparent is:
|
I could change the |
My understanding is that Windows command-line only supports double-quoted strings. |
I will replace the current |
The previous scp single-quote algorithm for pathnames worked well for POSIX servers but had problems on Windows servers, where single quotes are not recognized (just treated like normal characters). Use double quotes instead, and implement proper double-quoted escaping for POSIX strings. This gives 100% correct paths on POSIX servers but could still yield incorrect paths on Windows if the path contains unusual characters like $ or `. If the user requires 100% Windows compatibility they'll need to provide their own sanitizer function when communicating with a Windows server. Addresses issue jbardin#138 and issue jbardin#147
When trying to get a file such as
V:\test.txt
from a Windows host, this exception occurs:It looks like backslashes get converted to forward slashes which would make it impossible to copy anything from a Windows server to a Linux client. I also note that spaces in filenames passed to scp.SCPClient.get are treated as if scp is requesting multiple separate files, so it seems like there is both shell interpretation going on AND some unwarranted Linux-style translation of the path happening on a Linux client.
The text was updated successfully, but these errors were encountered: