# Using SSIS variables in a script

samspritzer
Joined:
Posts:
2
Location:
The Byte Mines

## Using SSIS variables in a script

I have an SSIS package that gets files from an FTP site. All of the files are downloaded at once. Then, SSIS loops through each file sets a variable to the file's name. Then it processes the file. This is the script to get the files...
option batch on
option confirm off
open sftp...
get /from-cfs/*Redemptions*.* \\SVRDWDB\etl\CoinFlip\
close
exit
As you can see, Redemptions has wildcards since there could be several for different times of the day.

After all of the files are processed, SSIS exits the loop and runs the script to delete the files.
option batch on
option confirm off
open sftp...
rm /test/from-cfs/*Redemptions*.*
close
exit
Ideally, I would like to include the delete task as part of the file processing so that after the file is archived, it should get deleted from the remote site. I know which file to delete because the file name is stored as an SSIS variable.

The question I have is....is it possible to pass this variable as part of the rm step? If so, how?

Sam

martin
Joined:
Posts:
35,996
Location:
Prague, Czechia

## Re: Using SSIS variables in a script

SSIS allows you to pass the variable to WinSCP command-line by using an expression in the Arguments property.

You can use /parameter switch to pass that further to the script, like:
"/script=c:\path\to\script.txt /parameter " + @Variable
Then in the script, use %1% to use that parameter:
rm /test/from-cfs/%1%
References:
https://winscp.net/eng/docs/scripting#arguments

khoa
Guest

## Re: Using SSIS variables in a script

hi martin

using this script below works for me but when i try to pass the parameter with the variable in..i get an error.

argument works here
/script=C:\WinSCP\SFTP_Batch_Script.txt /parameter extract*.txt

argument failed when i pass the the variable.
/script=C:\WinSCP\SFTP_Batch_Script.txt /parameter +@VFolderName

martin
Joined:
Posts:
35,996
Location:
Prague, Czechia

## Re: Using SSIS variables in a script

khoa wrote:

argument failed when i pass the the variable.
/script=C:\WinSCP\SFTP_Batch_Script.txt /parameter +@VFolderName
This does not look like the syntax I've posted above. You are missing the quotes. If this does not help, we need to know more than "failed". Though this is actually not a WinSCP question, so you better seek a support on an SSIS related site.

You can post new topics in this forum