I am calling the
WinSCP.com /script="%sftp_common_script%"
from Windows batch script (my.cmd).
I tested few failed scenarios, but it always return 0 for
%ERRORLEVEL%
. Does anyone know what is wrong with my code? Thank you!
In the my.cmd file:
WinSCP.com /ini=nul /console /script="%sftp_common_script%" /parameter "%sftp_user%" "%sftp_server%" "%sftp_ssh_key%" "%sftp_host_key%" "%%f" "./%au_printer%/%%~nf%%~xf"
IF %ERRORLEVEL% equ 0 (
ECHO %ERRORLEVEL%
exit /b 0
) ELSE (
ECHO %ERRORLEVEL%
exit /b 1
)
In the
%sftp_common_script%
file:
option batch abort
option confirm off
open sftp://%1%@%2%/ -privatekey="%3%" -hostkey="%4%"
put -resumesupport=off -transfer=b -nopermissions -nopreservetime %5% %6%
close
exit
Result:
C:\Program Files (x86)\WinSCP>C:\SVN\vw_sls_cde\CC\SFTP_Cypress_Print\my.cmd
Printing to DEV/QA Cypress...
..........................................................................
Printing C:\SVN\vw_sls_cde\CC\SFTP_Cypress_Print\SFTP_Cypress_test.pdf...
batch abort
confirm off
Searching for host...
Connecting to host...
Authenticating...
Using username "sftp-dlisshcypress".
Authenticating with public key "sftp-dlisshcypress-dev".
Authenticated.
Starting the session...
Session started.
Active session: [1] sftp-dlisshcypress@sftp-dev.vwoa.na.vwg
C:SFTP_Cypress_test.pdf | 0 B | 0.0 KB/s | binary | 0%
Cannot create remote file '/ftin_Incentive_AUDI2/SFTP_Cypress_test.pdf'.
General failure (server should provide error description).
Error code: 4
Error message from server: Folder not found: /ftin_Incentive_AUDI2/SFTP_Cypress_test.pdf
Common reasons for the Error code 4 are:
- Renaming a file to a name of already existing file.
- Creating a directory that already exists.
- Moving a remote file to a different filesystem (HDD).
- Uploading a file to a full filesystem (HDD).
- Exceeding a user disk quota.
(A)bort, (R)etry, (S)kip, Ski(p) all: Abort
ERRORLEVEL 0