Re: success notification on errorlevel 0
Got it! Thank you very much! :)
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
if ERRORLEVEL 0
means "if exit code is 0 or greater", what is always true.
if %ERRORLEVEL% equ 0
if /?
help.
winscp
command is run, i check for errorlevel
- 0
means call 'PROCESS_SUCCESS' notification email, else call 'PROCESS_ERROR' notification email. I have noticed that whether the winscp
command exited successfully or not, it always call the PROCESS_SUCCESS! Am I capturing the wrong ERRORLEVEL here for success/failure? I know it is failing because I am seeing a permission denied failure in the logs.
:WINSCP_SFTP_SCRIPT
for /f "tokens=*" %%z in (list.txt) do (
cd "%soucedir%"
set file=%%z
winscp.com /console /script=script.txt /log=ftp.log /parameter %%z %sourcedir%
if ERRORLEVEL 0 (
call :PROCESS_SUCCESS
) else (
call :PROCESS_ERROR
)
)
pause
script.txt
option batch abort
option confirm off
open XXXX_XXXXXXXX@XXX.XXXX.com -hostkey="ssh-dss blah blah"
lcd "%2%"
put %1%
close
exit
< 2014-05-29 13:26:49.058 Status code: 3, Message: 1372932, Server: Permission denied, Language: en
* 2014-05-29 13:26:49.058 (ETerminal) Permission denied.
* 2014-05-29 13:26:49.058 Error code: 3
* 2014-05-29 13:26:49.058 Error message from server (en): Permission denied
* 2014-05-29 13:26:49.058 Request code: 4
. 2014-05-29 13:26:49.059 Asking user:
. 2014-05-29 13:26:49.059 Cannot close remote file 'prdnssivr101_NEXTGEN_OSR_05282014.zip'. ("Permission denied.
. 2014-05-29 13:26:49.059 Error code: 3
. 2014-05-29 13:26:49.059 Error message from server (en): Permission denied
. 2014-05-29 13:26:49.059 Request code: 4")
< 2014-05-29 13:26:49.059 Script: Cannot close remote file 'prdnssivr101_NEXTGEN_OSR_05282014.zip'.
< 2014-05-29 13:26:49.060 Script: Permission denied.
< 2014-05-29 13:26:49.060 Error code: 3
< 2014-05-29 13:26:49.060 Error message from server (en): Permission denied
< 2014-05-29 13:26:49.060 Request code: 4
* 2014-05-29 13:26:49.061 (EScpSkipFile) Cannot close remote file 'prdnssivr101_NEXTGEN_OSR_05282014.zip'.
* 2014-05-29 13:26:49.061 Permission denied.
* 2014-05-29 13:26:49.061 Error code: 3
* 2014-05-29 13:26:49.061 Error message from server (en): Permission denied
* 2014-05-29 13:26:49.061 Request code: 4
. 2014-05-29 13:26:49.061 Script: Failed
. 2014-05-29 13:26:49.062 Script: Exit code: 1
. 2014-05-29 13:26:49.062 Closing connection.
. 2014-05-29 13:26:49.062 Sending special code: 12
. 2014-05-29 13:26:49.062 Sent EOF message