Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

FTP Connect Code in VB Script

Posted on 2008-10-29
6
3,162 Views
Last Modified: 2013-11-18
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

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

Expert Comment

by:nasserd
ID: 22834203
The code is not specifying the FTP Port as 2021 (as your statement says).  Maybe a different FTP component is necessary, too.
0
 
LVL 11

Author Comment

by:N R
ID: 22834412
I know, I need it to, but I don't know vb code.
0
 
LVL 4

Expert Comment

by:nasserd
ID: 22835643
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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 11

Author Comment

by:N R
ID: 22835879
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
 
LVL 4

Assisted Solution

by:nasserd
nasserd earned 250 total points
ID: 22836032
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
 
LVL 11

Accepted Solution

by:
N R earned 0 total points
ID: 22842772
Oh nope was in the code, it has ftpget it needed to be ftpput.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I made this because I wanted to get e-mail with a attached csv file so I'd would be able to import user input into a MS Excel template, but I also wanted to register/save all inputs from each day in a file on the server. 1st - It creates a temp C…
Before we dive into the marketing strategies involved with creating an effective homepage, it’s crucial that EE members know what a homepage is. In essence, a homepage is the introductory, or default page, of a website that typically highlights the …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 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