File upload 上载后关闭文件时出现WinSCP代码4错误

File upload 上载后关闭文件时出现WinSCP代码4错误,file-upload,scripting,command,winscp,File Upload,Scripting,Command,Winscp,大家好,编码员和编码员(?)我在使用WINSCP命令时遇到了一些问题…希望您能提供帮助 我有一个调用WinSCP命令行的powershell脚本 $LastFile = "$A\BC0722.txt" & 'C:\Program Files (x86)\WinSCP\WinSCP.com' /command "option batch abort" "option confirm off" "open sftp:BankOfTulsa/" "put $LastFile /incomin

大家好,编码员和编码员(?)我在使用WINSCP命令时遇到了一些问题…希望您能提供帮助

我有一个调用WinSCP命令行的powershell脚本

$LastFile = "$A\BC0722.txt"

& 'C:\Program Files (x86)\WinSCP\WinSCP.com' /command "option batch abort" "option confirm off" "open sftp:BankOfTulsa/" "put $LastFile /incoming/temp"
这部分很好用。它调用WinSCP没问题

Using username "usern".
Authenticating with pre-entered password.
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] BankOfTulsa
G:\FTP\A\ADropoff\BC0722.TXT |          2 KiB |    0.0 KiB/s | binary | 100%
Cannot close remote file 'temp'.
General failure (server should provide error description).
Error code: 4
Error message from server: Mailbox /clients/usern/pub/incoming/temp exists.
(A)bort, (R)etry, (S)kip, Ski(p) all: Abort
正如你所看到的,我得到一个错误,如上所述。。。它不加载文件,但直到无法关闭远程文件临时,它看起来不错…需要注意

Cannot close remote file 'temp'.
    General failure (server should provide error description).
    Error code: 4
    Error message from server: Mailbox /clients/usern/pub/incoming/temp exists.

我对WinSCP错误不太熟悉,我做了一些研究,但什么都没发现,有人知道这里发生了什么吗?

假设
/incoming/temp
是一个目录,您缺少一个尾随斜杠。你应使用:

put $LastFile /incoming/temp/
当您仅使用
/incoming/temp
时,这意味着您希望将文件上载到目录
/incoming
,并将其保存到文件
temp
。与同名的现有子目录明显冲突的内容

引用以下文件:

最后一个参数指定目标远程目录和可选的操作掩码以不同的名称存储文件。目标目录必须以斜杠结尾

正常情况下,当打开/创建文件
temp
时,上传应该会失败。但服务器似乎只在关闭文件时检测到冲突