Using FTP Task to grab multiple files

  • I need to develop a DTS package that goes to a FTP Site, grabs all of the .txt files in a particular directory and then loads each file into the database. Is any way to do this with the FTP Task or the execute process task? Help! Help!

  • The way I did this is not to use the FTP task.

    Create a ActiveX script with all the FTP commands to execute and a batch file with just FTP -s:"FTP commands file" in it.

    use a mget statement to get the files.

    only problem is that each file requires a y/n input. I'd suggest just putting in a number of "y" lines (at least as many as the number of files you expect ) heres a sample:

    Function Main()

    Dim fso

    Dim objTxtFile,

    Set fso = CreateObject("Scripting.FileSystemObject")

    ' Create the Text File

    Set objTxtFile = fso.CreateTextFile( "C:\Temp\FTPCommands.txt", TRUE)

    ' Write the Header

    objTxtFile.writeline( "open FtpSiteAddress" )

    objTxtFile.writeline( "MyLogin" )

    objTxtFile.writeline( "MyPassword" )

    objTxtFile.writeline( "cd Dir1" )

    objTxtFile.writeline( "cd Dir2" )

    objTxtFile.writeline( "lcd C:\FileDownloads" ) 'Change destination of downloaded files

    objTxtFile.writeline( "mGet *.xls " )

    objTxtFile.writeline( "Y" )

    objTxtFile.writeline( "Y" )

    objTxtFile.writeline( "Y" )

    objTxtFile.writeline( "quit" )

    objTxtFile.Close

    Set objTxtFile = fso.CreateTextFile( "C:\Temp\FTPExec.bat", TRUE)

    objTxtFile.writeLine( "Ftp -s:C:\Temp\FTPCommands.txt" )

    objTxtFile.Close

    Set objTxtFile = Nothing

    Set fso = Nothing

    Main = DTSTaskExecResult_Success

    End Function

    te next DTSStep would be a CmdExec Task with ftp as the Command

    And -s:C:\Temp\FTPCommands.txt as the parameter

    or just C:\Temp\FTPExec.bat as the Command

  • To avoid the prompting with mget, use the "prompt" command to turn off interactive prompting before you issue the mget.

  • Worked like a charm. Thanks.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply