winscp in batch file - exit code issue
Hi
I have an issue with my batch script. The upload is working fine, the part with the exit code not.
Any help much appreciated.
******************************************************************************************
@echo off
set WINSCP_RESULT=%ERRORLEVEL%
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\mydirectory\local\WinSCP.log" /ini=nul ^
/command ^
"open sftp://username:password@sftp.remoteserver.com/ -hostkey=""xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=""" ^
"lcd c:\mydirectory\local" ^
"cd upload" ^
"put *.xls" ^
"mv *.xls *.zip" ^
"exit"
if %WINSCP_RESULT% equ 0 (
C:\mydirectory\local\blat.exe -body "successfull" -from my@domain.com -to me@domain.com -subject "successfull" -server my.smtp.com:25
) else (
C:\mydirectory\local\blat.exe -body "failed" -from my@domain.com -to me@domain.com -subject "failed" -server my.smtp.com:25
)
exit /b %WINSCP_RESULT%
******************************************************************************************
I have an issue with my batch script. The upload is working fine, the part with the exit code not.
Any help much appreciated.
******************************************************************************************
@echo off
set WINSCP_RESULT=%ERRORLEVEL%
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\mydirectory\local\WinSCP.log" /ini=nul ^
/command ^
"open sftp://username:password@sftp.remoteserver.com/ -hostkey=""xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx=""" ^
"lcd c:\mydirectory\local" ^
"cd upload" ^
"put *.xls" ^
"mv *.xls *.zip" ^
"exit"
if %WINSCP_RESULT% equ 0 (
C:\mydirectory\local\blat.exe -body "successfull" -from my@domain.com -to me@domain.com -subject "successfull" -server my.smtp.com:25
) else (
C:\mydirectory\local\blat.exe -body "failed" -from my@domain.com -to me@domain.com -subject "failed" -server my.smtp.com:25
)
exit /b %WINSCP_RESULT%
******************************************************************************************