Solved

FTP Script

Posted on 2008-10-29
4
833 Views
Last Modified: 2013-11-18
I'm putting this VB code into a DTS package in MS SQL Server 2000.  I pieced it together from other thing I found on the net, but I don't know VB code and am getting an error:

Object Required FTP.

Also other than the fix for that does the rest of the code look ok for doing a transfer from a local file to a ftp server?
ftp.Hostname = "ftp.test.com"
	ftp.Username = "User"
	ftp.Password = "Pass"
 
	' The default data transfer mode is "Active" as opposed to "Passive".
	' Change it to Passive by setting the Passive property:
	ftp.Passive = 1
 
	'  Establish an AUTH SSL secure channel after connection
	'  on the standard FTP port 21.
	ftp.AuthTls = 1
 
	'  The Ssl property is for establishing an implicit SSL connection
	'  on port 990.  Do not set it.
	ftp.Ssl = 0
	'  Connect and login to the FTP server.
	connectStatus = ftp.Connect()
	If (connectStatus <> 1) Then
		'MsgBox ftp.LastErrorText
		'WScript.Quit
		Main = DTSTaskExecResult_Failure
	Else
		dirStatus = ftp.ChangeRemoteDir("RMed")
		If (dirStatus <> 1) Then
		    'MsgBox ftp.LastErrorText
		    'WScript.Quit
		Main = DTSTaskExecResult_Failure
	End If		
	
	
	
	'MsgBox ftp.getCurrentRemoteDir()
		
	'specify the file path and name on the local machine
	localInvoiceFile = "C:\Documents and Settings\Nathan\My Documents\2\dRMed\Invoice_RMed.txt"
	localPatientFile = "C:\Documents and Settings\Nathan\My Documents\2\dRMed\Patient_RMed.txt"
		
	'specify the file path and name on the remote machine
	remoteInvoiceFile = "C:\Clients\Strat\File Uploads\Customer Uploads\RMed\Invoice_RMed.txt"
	remotePatientFile = "C:\Clients\Strat\File Uploads\Customer Uploads\RMed\Patient_RMed.txt"
	'MsgBox remoteInvoiceFile 
	'MsgBox remotePatientFile
		
		'download the files from the remote server
		transferStatus = ftp.getFile(remoteInvoiceFile, localInvoiceFile)
		if (transferStatus <> 1) then
			'MsgBox ftp.LastErrorText
			Main = DTSTaskExecResult_Failure
		else
			Main = DTSTaskExecResult_Success
		end if
		
		transferStatus = ftp.GetFile(remotePatientFile, localPatientFile)
		if (transferStatus <> 1) then
			'MsgBox ftp.LastErrorText
			Main = DTSTaskExecResult_Failure
		else
			Main = DTSTaskExecResult_Success
		end if
	
	END IF
	ftp.Disconnect 	
 
End Function

Open in new window

0
Comment
Question by:N R
  • 3
4 Comments
 
LVL 2

Expert Comment

by:Dudge669
ID: 22833354
You need to download an FTP object activex to be able to use it.  As far as your syntax goes, it depends on which object the syntax was coded for.  Check out this link:

http://www.robvanderwoude.com/vbstech_internet_ftp.html
0
 
LVL 2

Expert Comment

by:Dudge669
ID: 22833411
Here's another link showing how you create the Chilkat ftp object and use it...

http://www.example-code.com/vbscript/ftp_asyncDownload.asp
0
 
LVL 11

Author Comment

by:N R
ID: 22833489
ok I see this in the code I took it from:

set ftp = CreateObject("Chilkat.Ftp2")

That's off my production server, so I assume that the FTP object is loaded on it.  However I'm going to be running this on my dev server so I guess I need to get it for it as well?
0
 
LVL 2

Accepted Solution

by:
Dudge669 earned 500 total points
ID: 22833511
Yes, you will need to install the chillkat object on whatever machine your script runs on.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question