Fail SSIS task when the mask to select files to be

2020-03-26 08:11发布

I'm creating a SSIS package that uses a script task (via WinSCP) to upload a file to an FTP.

The upload works fine, however I need the process to fail if there is no file uploaded (currently it just loops through and passes a success) - Haven't had any luck getting help on scripting it in the WinSCP command file.

option batch on 
option confirm off 
open ftps://username:password@ftpsaddress/ -implicit -certificate="xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" 
cd "/DIR/" 
option transfer binary 
put \\SERVER\Reports_BackUp\SFTP\*.csv -nopermissions -nopreservetime 
close 
exit 

So my logic is to build a pre-run file check process before the process task runs. the file name varies greatly however it will always be a .csv. This is where I'm stuck. I need to add a task in that checks that a .csv file is there and then pass a fail or success on that basis.

1条回答
ら.Afraid
2楼-- · 2020-03-26 08:56

Assuming SSIS monitors process exit code, you can make WinSCP return exit code 1 by using option failonnomatch on:

option failonnomatch on
put ...
查看更多
登录 后发表回答