FTP Connect Code in VB Script

I am trying to edit the following code so that I can connect:

explict TLS/SSL
port: 2021
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

LVL 12
Nathan RileyFounderAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nasserdCommented:
The code is not specifying the FTP Port as 2021 (as your statement says).  Maybe a different FTP component is necessary, too.
0
Nathan RileyFounderAuthor Commented:
I know, I need it to, but I don't know vb code.
0
nasserdCommented:
Hmm.  You may need to verify with the FTP ActiveX Component being used.  From the comments included, it may be a Chilkat FTP component; usually it would be object.Port = 1234

e.g.
ftp.HostPort = 2021 or
ftp.Port = 2021

As we don't know the exact component being used, there's more trial and error necessary.  Windows, by default, doesn't expose all of these parameters in its own FTP command-line tool.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Nathan RileyFounderAuthor Commented:
Ok got it.  Now getting error:


Step Error Source: Microsoft Data Transformation Services (DTS) Package
Step Error Description:The task reported failure on execution.
Step Error code: 8004043B
Step Error Help File:sqldts80.hlp
Step Error Help Context ID:1100
'**********************************************************************
'  Visual Basic ActiveX Script
'************************************************************************
 
Function Main()	
 
	set ftp = CreateObject("Chilkat.Ftp2")
 
	'  Any string unlocks the component for the 1st 30-days.
	componentStatus = ftp.UnlockComponent("testftp")
	If (componentStatus <> 1) Then
		'MsgBox ftp.LastErrorText
		WScript.Quit
		Main = DTSTaskExecResult_Failure
	End If
	
 
            ftp.Hostname = "IP"
            ftp.Username = "user"
            ftp.Password = "pass"
            ftp.Port = 2021
 
       ' 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("/File Uploads/Customer Uploads/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\dRickMed\Invoice_RMed.txt"
		localPatientFile = "C:\Documents and Settings\Nathan\My Documents\2\dRickMed\Patient_RMed.txt"
		
		'specify the file path and name on the remote machine
		remoteInvoiceFile = "Invoice_RMed.txt"
		remotePatientFile = "Patient_RMed.txt"
		'MsgBox remoteInvoiceFile 
		'MsgBox remotePatientFile
		
		'download the files from the remote server
		transferStatus = ftp.getFile(localInvoiceFile, remoteInvoiceFile)
		if (transferStatus <> 1) then
			'MsgBox ftp.LastErrorText
			Main = DTSTaskExecResult_Failure
		else
			Main = DTSTaskExecResult_Success
		end if
		
		transferStatus = ftp.GetFile(localPatientFile, remotePatientFile)
		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
nasserdCommented:
SQL DTS, eh?  That's a different buggaboo!  You're best off re-categorizing this issue into the SQL Server categories... FTP via DTS has been a bane of my own existence, too.

Try declaring all of the variables (DIM xyz) and read this eggheadcafe sample:
http://www.eggheadcafe.com/articles/20030923.asp
0
Nathan RileyFounderAuthor Commented:
Oh nope was in the code, it has ftpget it needed to be ftpput.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Components

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.