The sample script below will access a defined SFTP Server.
See also SFTPClient documentation under Automation > Automated Miscellaneous.
Note: There is also an FTPClient Object.
Dim SFTP as object
SFTP = CreateObject("Accredo.SFTPClient")
SFTP.Host = "MySFTPHost"
SFTP.Username = "MySFTPUserName"
' If Public/Private key is required both must be provided as PEM files.
SFTP.PrivateKey = "c:\data\private_key.pem" 'location of private key on file system
SFTP.PublicKey = "c:\data\public_key.pem" 'location of public key on file system
SFTP.Connect
If Not SFTP.connected Then Error("Error connecting to SFTP server.")
' upload a selected file
sMesg = "Select a Txt File to Push to the SFTP Site"
SelectedFile = InputFileOpen("File:", SMesg,"C:\","Text Files(*.txt)|*.txt")
If IsNull(SelectedFile) Then Abort("User pressed cancel")
If SelectedFile <> "" then
' extract filename only from fullpath
FileName = Mid(SelectedFile,InstrRev(SelectedFile,"\") + 1)
' specify a directory on the SFTP server
SFTP.CurrentDirectory = "\MyDirectory"
SFTP.Put(SelectedFile,FileName)
End If
' download the same file back
DownloadFile = "c:\MyDownloadFile.txt"
SFTP.Get(FileName, Downloadfile)
' print contents of SFTP Directory
Dim Dir as Object
Dir = SFTP.Dir("", True)
For I = 1 to Dir.LineCount
Print Dir.GetLine(I)
Next
SFTP.Quit