October 28, 2005 at 4:13 am
Can any body tell me how to push the local file to FTP.
I tried using WScript but its throwing an error
saying "---------------------------
Package Error
---------------------------
Error Source : Microsoft Data Transformation Services (DTS) Package
Error Description : Error Code: 0
Error Source= Microsoft VBScript runtime error
Error Description: Object required: 'WScript'
Error on Line 63
---------------------------
OK
------------------------"
The following script used in active X script task
'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************
Function Main()
'Option Explicit
Dim objFSO, objMyFile, objShell, strFTPScriptFileName, strFile2Get,WScript
Dim strLocalFolderName, strFTPServerName, strLoginID
Dim strPassword, strFTPServerFolder
'Customize code here to fit your needs
strLocalFolderName = "E:\FTPSource"
strFTPServerName = "FTP server IP"
strLoginID = "username"
strPassword = "Password"
strFTPServerFolder = "Reports"
'The following code generates the file name on the FTP server you want to get
'strFile2Get = "Data" & strFile2Get & ".csv"
'strFile2Get = "E:\FTPSource\MoveFileFTP.txt"
strFile2Get = "MoveFileFTP.CSV"
'The follow lines of code generate the FTP script file on the fly,
'because the get file name changes every day
strFTPScriptFileName = strLocalFolderName & "\FTPScript.txt"
Set objFSO = CreateObject("Scripting.FileSystemObject")
If (objFSO.FileExists(strFTPScriptFileName)) Then
objFSO.DeleteFile (strFTPScriptFileName)
End If
Set objMyFile = objFSO.CreateTextFile(strFTPScriptFileName, True)
objMyFile.WriteLine ("open " & strFTPServerName)
objMyFile.WriteLine (strLoginID)
objMyFile.WriteLine (strPassword)
objMyFile.WriteLine ("cd " & strFTPServerFolder)
objMyFile.WriteLine ("ascii")
objMyFile.WriteLine ("lcd " & strLocalFolderName)
'objMyFile.WriteLine ("get " & strFile2Get)
objMyFile.WriteLine ("put " & strFile2Get)
objMyFile.WriteLine ("bye")
objMyFile.Close
Set objFSO = Nothing
Set objMyFile = Nothing
'The following code executes the FTP script. It creates a Shell
'object and run FTP program on top of it.
Set objShell = WScript.CreateObject( "WScript.Shell" )
objShell.Run ("ftp -s:" & chr(34) & strFTPScriptFileName & chr(34))
Set objShell = Nothing
Main = DTSTaskExecResult_Success
End Function
Pls let me know any clarification reqd
Reqd solution ASAP
THanks in Advance
Manoj
October 29, 2005 at 2:56 am
Change the line:
Set objShell = WScript.CreateObject( "WScript.Shell" )
to
Set objShell = CreateObject( "WScript.Shell" )
-Mike Gercevich
October 30, 2005 at 3:23 pm
Or even better get the DTSFTP task from http://www.sqldts.com. This custom task supports both get and put operations unlike the inbuilt FTP task.
--------------------
Colt 45 - the original point and click interface
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply