I've written a basic .bat
file script that automates downloading a group of files via WinSCP. I have used this code for performing a similar process which is working as intended, however the stumbling block appears to be the destination filepath. I have tried using
C:Users"John Smith"DropboxjoebloggsData"System Data""Raw Feeds"StockMay
and other variations with the whole filepath within inverted commas also. If anyone could advise the correct syntax for entering this filepath it would be appreciated. Code is as follows:-
@echo off
"C:Program Files (x86)WinSCPWinSCP.com" ^
/log="C:UsersJohn SmithDocumentsWinSCP.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:UsersJohn SmithDropboxjoebloggsDataSystem DataRaw FeedsStockMay" ^
"exit"
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
echo Success
) else (
echo Error
)
exit /b %WINSCP_RESULT%
Error Log is as follows:-
> 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:UsersJohn.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:UsersJohn.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:UsersDaniel.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
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…