Skip to main content

We use the 32-bit Chilkat ActiveX controls (http://www.chilkatsoft.com) for several functions in the 32-bit Windows runtime (currently on 9.2.2 ECN-4266).  One is doing file transfers (FTP, FTPS, and SFTP).  We have been using the FTP portion for a few years.  We have a new vendor that is using SFTP.  I can use the Chilkat control to successfully Connect, AuthenticatePw, and InitializeSftp.  After these steps for SFTP, I have to open a handle for the file on the remote server, then upload the file using the handle created by the open command.  I'm not getting the handle from the open to use for the upload.

From the VB example (https://www.example-code.com/vb/sftp_uploadFile.asp):
Dim handle As String
handle = sftp.OpenFile("hamlet.xml","writeOnly","createTruncate")

From the control's .def file:
*[Class: @IChilkatSFtp] OpenFile
      METHOD, 176, @OpenFile,
         "BSTR" @remoteFilePath, TYPE 8,
         "BSTR" @access, TYPE 8,
         "BSTR" @createDisp, TYPE 8
            RETURNING "BSTR", TYPE 8

My COBOL command:
MODIFY SFTP-handle @OpenFile(full-remote-filename, "writeOnly", "createTruncate") GIVING remoteHandle

For my "01 remoteHandle" in WORKING-STORAGE, I've tried PIC X(50), PIC X(500), USAGE HANDLE, USAGE SIGNED-INT, and USAGE UNSIGNED-INT.  When I do "DISPLAY MESSAGE remoteHandle", the value in remoteHandle is "00000000" (8 zeroes) when using a PIC and "0000000000" (10 zeroes) when using one of the USAGE types.

I do know the @OpenFile command is working because I have the folder on the remote server open in FileZilla and a 0-byte file appears using my filename from "full-remote-filename" when I get to the message box after the @OpenFile command.  I tried the UploadFile command using the handles just in case any of them were correct, but the file size never changes.

I can't figure out how to get the correct handle (or maybe I'm not doing the MODIFY command correctly).  Any thoughts?


#ActiveX

We use the 32-bit Chilkat ActiveX controls (http://www.chilkatsoft.com) for several functions in the 32-bit Windows runtime (currently on 9.2.2 ECN-4266).  One is doing file transfers (FTP, FTPS, and SFTP).  We have been using the FTP portion for a few years.  We have a new vendor that is using SFTP.  I can use the Chilkat control to successfully Connect, AuthenticatePw, and InitializeSftp.  After these steps for SFTP, I have to open a handle for the file on the remote server, then upload the file using the handle created by the open command.  I'm not getting the handle from the open to use for the upload.

From the VB example (https://www.example-code.com/vb/sftp_uploadFile.asp):
Dim handle As String
handle = sftp.OpenFile("hamlet.xml","writeOnly","createTruncate")

From the control's .def file:
*[Class: @IChilkatSFtp] OpenFile
      METHOD, 176, @OpenFile,
         "BSTR" @remoteFilePath, TYPE 8,
         "BSTR" @access, TYPE 8,
         "BSTR" @createDisp, TYPE 8
            RETURNING "BSTR", TYPE 8

My COBOL command:
MODIFY SFTP-handle @OpenFile(full-remote-filename, "writeOnly", "createTruncate") GIVING remoteHandle

For my "01 remoteHandle" in WORKING-STORAGE, I've tried PIC X(50), PIC X(500), USAGE HANDLE, USAGE SIGNED-INT, and USAGE UNSIGNED-INT.  When I do "DISPLAY MESSAGE remoteHandle", the value in remoteHandle is "00000000" (8 zeroes) when using a PIC and "0000000000" (10 zeroes) when using one of the USAGE types.

I do know the @OpenFile command is working because I have the folder on the remote server open in FileZilla and a 0-byte file appears using my filename from "full-remote-filename" when I get to the message box after the @OpenFile command.  I tried the UploadFile command using the handles just in case any of them were correct, but the file size never changes.

I can't figure out how to get the correct handle (or maybe I'm not doing the MODIFY command correctly).  Any thoughts?


#ActiveX
Kept trying different values. Since the USAGE were returning 10 zeroes, I tried a PIC X(10). That worked. Hopefully, this might help someone else. Thanks!