Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

Re: %ERRORLEVEL% is always 0

Your script looks good. There's probably some tiny syntax problem that you post does not show.
Check this: https://winscp.net/eng/docs/faq_batch_file#newline_escaping

What do you get if you put ECHO ERRORLEVEL %ERRORLEVEL% right after the "exit" line?

This is wrong: "ls "%FTP_DIR_LIVE%"" it should be:
    "ls ""%FTP_DIR_LIVE%""" ^

What do you get if you try this?
winscp.com /command "foo"
echo %ERRORLEVEL%
Tina_ls

%ERRORLEVEL% is always 0

Hello
I have a problem.
I'm using the below script.
"F:\Tools\WinSCP_51710\WinSCP.com" ^
  /log="F:\Tools\WinSCP_51710\WinSCP_51710.log" /ini=nul ^
  /command ^
    "option batch abort" ^
    "open ftp://%ftp_username%:%ftp_password%@%FTP_IP% -explicit -certificate=*" ^
    "ls "%FTP_DIR_LIVE%"" ^
    "exit"
 
set WINSCP_RESULT=%ERRORLEVEL%
if %WINSCP_RESULT% equ 0 (
  echo Success
) else (
  echo Error
)
ECHO ERRORLEVEL %ERRORLEVEL%

But %WINSCP_RESULT% is always 0 even if the log remains "Script: Exit code: 1".
I want to get the real error code.
Please advise.
Thank you.