Post a reply

Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)


Topic review


Scripting Assistance

What am I missing??? Say's object required and its not uploading.

Getting error:
Error opening SFTP session: Object required

With objSFTPSessionOptions
    .PortNumber = 2224
    .Protocol = 0
    .HostName = SFTP_HOST_NAME
    .UserName = strSFTPUsername
    .Password = "password"
    '.PrivateKeyPassphrase = SFTP_KEY_PASSPHRASE
    .SshHostKeyFingerprint = SSH_HOST_KEY
End With
On Error Resume Next
Set objSFTPSession = WScript.CreateObject("WinSCP.Session")
' Connect
objSFTPSession.Open objSFTPSessionOptions
If Err.Number <> 0 Then
   AmendLog "Error opening SFTP session: " & Err.Description
   processFile = False
   Exit Function
End If
' Upload files
Set objSFTPTransferOptions = WScript.CreateObject("WinSCP.TransferOptions")
objSFTPTransferOptions.TransferMode = TransferMode_Binary
Set objSFTPTransferResults = objSFTPSession.PutFiles(strDestinationPath, SFTP_SUBFOLDER, False, objSFTPTransferOptions)
' Throw on any error
' Print results
For Each objSFTPTransferResult In objSFTPtransferResults.Transfers
   If objSFTPTransferResult.Error = Null Then
      AmendLog "Upload of " & objSFTPTransferResult.FileName & " succeeded"
      bolTransferSuccess = True
      'Move file to processed folder
      AmendLog "Moving processed file to Submitted folder"
      objFSO.MoveFile strDestinationPath, PROCESSED_FILE_DIRECTORY & "\" & strDestinationFileName
      AmendLog "Upload of " & objSFTPTransferResult.FileName & " failed with error " & objSFTPTransferResult.Error.Message
      bolTransferSuccess = False
   End If
' Disconnect, clean up
'Clean up
Set objRecord = Nothing
Set objConn = Nothing
Set objSourceFile = Nothing
Set objFSO = Nothing
'Check for presence of failed transfer of one or more files
If bolTransferSuccess = True Then
   processFile = True
   processFile = False
End If
End Function