Capturing Error Code 4 into my flag file

Advertisement

Saradevi
Joined:
Posts:
5
Location:
USA

Capturing Error Code 4 into my flag file

Hi Martin,
This is SaraDevi and i am new to the Winscp Batch script.Please help and really appreciate it.
I am using the below script to send a flag when script returns error codes.

if %ERRORLEVEL% equ 1 goto error
if %ERRORLEVEL% equ 0 goto success

:succes
echo
"Success" > "\\hqolymappim3q\Informatica\PowerCenter Server\FlagFiles\LaborReplacementSystem\EarningLeaveBalanceExport\HRMSEarningLeaveBalanceExportFileDownloadedSuccessFully.txt"

exit /b 0
:end

:error
echo "Error" > "\\hqolymappim3q\Informatica\PowerCenter Server\FlagFiles\LaborReplacementSystem\EarningLeaveBalanceExport\HRMSEarningLeaveBalanceExportFileNotDownloaded.txt"

exit /b 1
:end
But it didnt write the HRMSEarningLeaveBalanceExportFileNotDownloaded.txt even though script returns exit code 1.
Could you please help if i am doing anything wrong.
Also please find the log attached to the post and do let me know if i am doing anything wrong.

Thanks,
SaraDevi
  • HRMSEarningLeaveBalanceExport_20180926113654.log (10.75 KB, Private file)

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Your batch file works for me just fine.
So when you get "error 4", is a record stored to HRMSEarningLeaveBalanceExportFileDownloadedSuccessFully.txt?

Reply with quote

Advertisement

Saradevi
Joined:
Posts:
5
Location:
USA

Capturing Error Code 4 into my flag file

No, it should write to HRMSEarningLeaveBalanceExportFileNotDownloaded.txt as an Error but it is not writing.
Error Code 4 and its corresponding message information is writing only to log file i.e.,
\\hqolymappim3q\Informatica\PowerCenter Server\FlagFiles\LaborReplacementSystem\EarningLeaveBalanceExport\HRMSEarningLeaveBalanceExport_!Y!M!D!T.log

Please find the script below to capture errors and my SFTP process should fail or aborts.

if %ERRORLEVEL% neq 0 goto error
if %ERRORLEVEL% equ 0 goto success

:success
echo
"Success" >> "\\hqolymappim3q\Informatica\PowerCenter Server\FlagFiles\LaborReplacementSystem\EarningLeaveBalanceExport\HRMSEarningLeaveBalanceExportFileDownloadedSuccessFully.txt"

exit /b 0
:end

:error
echo "Error" >> "\\hqolymappim3q\Informatica\PowerCenter Server\FlagFiles\LaborReplacementSystem\EarningLeaveBalanceExport\HRMSEarningLeaveBalanceExportFileNotDownloaded.txt"

exit /b 1
:end

Also if there is an error it should goto the error echo statement but it is not happening.Is there anything i need to make the code change.

Reply with quote

martin
Site Admin
martin avatar

Re: Capturing Error Code 4 into my flag file

Saradevi wrote:

No, it should write to HRMSEarningLeaveBalanceExportFileNotDownloaded.txt as an Error but it is not writing.
I've meant, if you get a record stored (incorrectly) in the "success" branch. Or if you do not get any record at all.

Reply with quote

Advertisement

You can post new topics in this forum