psftp put抛出错误<dir>:打开写入:在目标位置未提供文件名时失败

时间:2018-06-05 18:16:08

标签: sftp putty psftp

我使用psftp的put命令上传文件。假设文件将使用相同的名称进行复制,我不会在目标位置提供文件名。这是put命令的帮助页面

psftp> help put
put [ -r ] [ -- ] <filename> [ <remote-filename> ]
Uploads a file to the server and stores it there under
the same name, or under a different one if you supply the
argument <remote-filename>.
If -r specified, recursively store a directory.

如果我尝试在目标位置使用没有文件名的PUT,psftp会抛出错误打开以进行写入:失败

psftp> open user@host
Using username "user".
Remote working directory is /
psftp> put <file_name> ./<dir>/
/<dir>: open for write: failure

如果我在目的地位置提供文件名,那么它可以正常工作

psftp> put <file_name> ./<dir>/<file_name>
local:<file_name> => remote:/<dir>/<file_name>

为什么PUT命令在目标位置需要文件名?

1 个答案:

答案 0 :(得分:1)

帮助页面意味着整个<remote-filename>参数是可选的,而不是参数的文件名部分。

所以你可以这样做

put <file_name>

它将文件以相同的文件名上传到当前的远程工作目录。

但你不能这样做:

put <file_name> ./<dir>/

你可以这样做:

cd ./<dir>
put <file_name>
相关问题