我已经编写了一个基本的.bat
文件脚本,可以通过WinSCP自动下载一组文件。我已经使用此代码执行类似的过程,该过程按预期工作,但是障碍块似乎是目标文件路径。我尝试过使用
C:\Users\"John Smith"\Dropbox\joebloggs\Data\"System Data"\"Raw Feeds"\Stock\May\
和其他变体与翻译逗号中的整个文件路径也是如此。如果有人可以建议输入此文件路径的正确语法,将不胜感激。代码如下: -
@echo off
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\Users\John Smith\Documents\WinSCP.log" /ini=nul ^
/command ^
"open sftp://joebloggs:%%40faNliGHT4@82.121.124.146/ -hostkey=""ssh-rsa 1024 01:01:dd:1c:54:72:98:c7:42:f9:15:8e:30:8c:66:3b"" -passive=0" ^
^
"get "/*.txt" "C:\Users\John Smith\Dropbox\joebloggs\Data\System Data\Raw Feeds\Stock\May\" ^
"exit"
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
echo Success
) else (
echo Error
)
exit /b %WINSCP_RESULT%
错误日志如下: -
> 2016-05-16 13:32:43.902 Access is denied
. 2016-05-16 13:32:43.902 Asking user:
. 2016-05-16 13:32:43.902 Can't create file 'C:\Users\John.filepart'. ("System Error. Code: 5.
> 2016-05-16 13:32:43.902 Access is denied")
< 2016-05-16 13:32:43.902 Script: Can't create file 'C:\Users\John.filepart'.
< 2016-05-16 13:32:43.902 Script: System Error. Code: 5.
> 2016-05-16 13:32:43.902 Access is denied
> 2016-05-16 13:32:43.903 Type: SSH_FXP_CLOSE, Size: 23, Number: 2052
> 2016-05-16 13:32:43.903 (EScpSkipFile) Can't create file 'C:\Users\Daniel.filepart'.
> 2016-05-16 13:32:43.903 System Error. Code: 5.
> 2016-05-16 13:32:43.903 Access is denied
> 2016-05-16 13:32:43.903 Script: Failed
> 2016-05-16 13:32:43.903 Script: Exit code: 1
> 2016-05-16 13:32:43.903 Closing connection.
> 2016-05-16 13:32:43.903 Sending special code: 12
> 2016-05-16 13:32:43.903 Sent EOF message
答案 0 :(得分:1)
你必须加倍双引号。您在get
命令的末尾也缺少引号(请注意连续三个引号)。
"get ""/*.txt"" ""C:\Users\John Smith\Dropbox\joebloggs\Data\System Data\...\""" ^
(缩短路径以使其适合视图)