SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Script for FTP transfer
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

masterdineen
Aged Yak Warrior

United Kingdom
548 Posts

Posted - 01/16/2013 :  17:30:13  Show Profile  Reply with Quote
Hello there.

does anyone know of a simple or common script for FTP transfer.

I would like to look for a file with the same file name but looking for the oldest newest version.

Regards

Rob

James K
Flowing Fount of Yak Knowledge

3559 Posts

Posted - 01/17/2013 :  04:14:17  Show Profile  Reply with Quote
Can you use the FTP task in SSIS?

There is a Powershell FTP script here: http://gallery.technet.microsoft.com/scriptcenter/PowerShell-FTP-Client-db6fe0cb I have not used it myself, but seems to be actively maintained.

I have not used either of the above. Couple of years ago when I was trying to do something similar, I really did not find anything that met my needs. Ideally I would like the FTP script to accept regular expressions for file names and other parameters. I ended up writing one for myself - not robust enough to distribute, otherwise I would have.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 01/17/2013 :  04:26:58  Show Profile  Reply with Quote
here's a solution if you want to use Secured FTP

http://visakhm.blogspot.in/2012/12/implementing-dynamic-secure-ftp-process.html

Otherwise you can use FTP stndard task that comes with SSIS

you can configure all properties like URL,filename atc to be expression based inside SSIS



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

masterdineen
Aged Yak Warrior

United Kingdom
548 Posts

Posted - 01/17/2013 :  05:57:36  Show Profile  Reply with Quote
ok thank you.

This will need to run once a day, picking up a certain file name, for example. todaysfile17012013.txt

so i will need to search on the todaysfile part, then code in the date part.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 01/17/2013 :  06:00:41  Show Profile  Reply with Quote
quote:
Originally posted by masterdineen

ok thank you.

This will need to run once a day, picking up a certain file name, for example. todaysfile17012013.txt

so i will need to search on the todaysfile part, then code in the date part.


yes. you can do similar logic as below

http://visakhm.blogspot.in/2012/05/package-to-implement-daily-processing.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

masterdineen
Aged Yak Warrior

United Kingdom
548 Posts

Posted - 01/18/2013 :  07:59:38  Show Profile  Reply with Quote
Hello there. i have got as far as the script task in the walk through above.

when i open the edit script screen via the script task i get the following.

/*
Microsoft SQL Server Integration Services Script Task
Write scripts using Microsoft Visual C# 2008.
The ScriptMain is the entry point class of the script.
*/

using System;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using System.Windows.Forms;

namespace ST_6f7a7d21d7b14a93ad84b9635bd9dec2.csproj
{
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{

#region VSTA generated code
enum ScriptResults
{
Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
};
#endregion

/*
The execution engine calls this method when the task executes.
To access the object model, use the Dts property. Connections, variables, events,
and logging features are available as members of the Dts property as shown in the following examples.

To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
To post a log entry, call Dts.Log("This is my log text", 999, null);
To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);

To use the connections collection use something like the following:
ConnectionManager cm = Dts.Connections.Add("OLEDB");
cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";

Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.

To open Help, press F1.
*/

public void Main()
{
// TODO: Add your code here
Dts.TaskResult = (int)ScriptResults.Success;
}
}
}

the walk through suggests

public sub main()
'
'add your code here
'
dts.taskresult = scriptResults.success
Dim currentday as sring
currentday = now().toString("yyymmdd")
Dts.Variables("Currentdayfile").Value = IIf(InStr(Dts.Variables("Filename").value, currentDay) > 0, true, false)

where would i insert the script. Also the walk through does not explain how to set the FTP task up
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 01/18/2013 :  13:41:47  Show Profile  Reply with Quote
you're trying to put vb .net code inside c#. if you're planning to use my vb.net code snippet you need to first change script language from c# to vb in script task properties. Then the code should be put under section where comment says add your code here.

I'm not using FTP task in my example. So if you're using standard FTP task see below on how to setup arguments.

http://www.sqlservergeeks.com/blogs/raunak.jhawar/sql-server-bi/398/sql-server-2012-ssis-sending-files-using-ftp-task



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000