Skip to main content

I am trying to convert a C# sample (ftp from AlexPilotti) to AcuCobol, but the second part is not clear to me.
Maybe someone can help me with this sample.

 

https://archive.codeplex.com/?p=ftps


using AlexPilotti.FTPS.Client;
using AlexPilotti.FTPS.Common;
using System.Net;


class Test
{
    public static void Main()
    {
           using (FTPSClient client = new FTPSClient())
           {
               // Connect to the server, with mandatory SSL/TLS
              // encryption during authentication and
              // optional encryption on the data channel
              // (directory lists, file transfers)
              client.Connect("ftp.yourserver.com",
                               new NetworkCredential("yourUsername",
                                                                                "yourPassword"),
                                ESSLSupportMode.CredentialsRequired |
                                ESSLSupportMode.DataChannelRequested);

               // Download a file
                   client.GetFile("/path/to/remotefile.jpg", "c:\\\\local\\\\path\\\\");
             }
        }
}


Part of NETDEFGEN

 

* FULLY-QUALIFIED-NAME AlexPilotti.FTPS.Client.FTPSClient, AlexPilotti.FTPS.Client, Version=1.1.0.27735, Culture=neutral, PublicKeyToken=48316da1e84b328d

* AlexPilotti.FTPS.Client.FTPSClient
NAMESPACE "AlexPilotti.FTPS.Client"
CLASS "FTPSClient"
MODULE "AlexPilotti.FTPS.Client.dll"
CONSTRUCTOR, 0, @CONSTRUCTOR1

* [Class: FTPSClient] System.String Connect(System.String)
METHOD, 0, "@Connect"
"BSTR" @hostname, TYPE 8
RETURNING "BSTR", TYPE 8

* [Class: FTPSClient] System.String Connect(System.String, AlexPilotti.FTPS.Client.ESSLSupportMode)
METHOD, 0, "@Connect"
"BSTR" @hostname, TYPE 8
"int" @sslSupportMode, TYPE 3
RETURNING "BSTR", TYPE 8

 

AcuCobol source

 

IDENTIFICATION DIVISION.
PROGRAM-ID. SFTP.
AUTHOR. EB.
DATE-WRITTEN. 01/01/21.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. RMC.
OBJECT-COMPUTER. RMC.

special-names.

COPY "D:\\FTPS\\AlexPilotti.FTPS.Client.DEF"..

DATA DIVISION.
WORKING-STORAGE SECTION.

copy "P:\\AcuCorp\\AcuGT\\sample\\def\\acucobol.def".
copy "P:\\AcuCorp\\AcuGT\\sample\\def\\acugui.def".
copy "P:\\AcuCorp\\AcuGT\\sample\\def\\crtvars.def".
copy "P:\\AcuCorp\\AcuGT\\sample\\def\\controls.def".
copy "P:\\AcuCorp\\AcuGT\\sample\\def\\opensave.def".


77 WS-STATUS PIC 9(04) VALUE 0.
77 WS-STRING PIC X(256) VALUE SPACES.

77 MY-ASSY-HANDLE USAGE IS HANDLE.
77 MY-ASSY-HANDLE-FTPSClient USAGE IS HANDLE.

*----------------------------------------------------------------
PROCEDURE DIVISION.
MAIN-PROG SECTION.
INIT-PARAM.

CREATE "AlexPilotti.FTPS.Client"
            NAMESPACE IS "AlexPilotti.FTPS.Client",
           CLASS-NAME IS "FTPSClient",
           CONSTRUCTOR IS CONSTRUCTOR1(),
                    HANDLE IS MY-ASSY-HANDLE.

 

Can someone help met with the connect statement.
I have to translate ... using (FTPSClient client = new FTPSClient())
But it is not clear for me how.

From here (connect) Undefined data item: FTPSCLIENT

MODIFY MY-ASSY-HANDLE
                       ("ftp.server.com",
                       "ftp_login_naam",
                         "password"
                        ) GIVING WS-STRING.

 

And  how to convert the download

// Download a file
client.GetFile("/path/to/remotefile.jpg", "c:\\\\local\\\\path\\\\");

 

          ENDS.

                  stop run.

 

I am trying to convert a C# sample (ftp from AlexPilotti) to AcuCobol, but the second part is not clear to me.
Maybe someone can help me with this sample.

 

https://archive.codeplex.com/?p=ftps


using AlexPilotti.FTPS.Client;
using AlexPilotti.FTPS.Common;
using System.Net;


class Test
{
    public static void Main()
    {
           using (FTPSClient client = new FTPSClient())
           {
               // Connect to the server, with mandatory SSL/TLS
              // encryption during authentication and
              // optional encryption on the data channel
              // (directory lists, file transfers)
              client.Connect("ftp.yourserver.com",
                               new NetworkCredential("yourUsername",
                                                                                "yourPassword"),
                                ESSLSupportMode.CredentialsRequired |
                                ESSLSupportMode.DataChannelRequested);

               // Download a file
                   client.GetFile("/path/to/remotefile.jpg", "c:\\\\local\\\\path\\\\");
             }
        }
}


Part of NETDEFGEN

 

* FULLY-QUALIFIED-NAME AlexPilotti.FTPS.Client.FTPSClient, AlexPilotti.FTPS.Client, Version=1.1.0.27735, Culture=neutral, PublicKeyToken=48316da1e84b328d

* AlexPilotti.FTPS.Client.FTPSClient
NAMESPACE "AlexPilotti.FTPS.Client"
CLASS "FTPSClient"
MODULE "AlexPilotti.FTPS.Client.dll"
CONSTRUCTOR, 0, @CONSTRUCTOR1

* [Class: FTPSClient] System.String Connect(System.String)
METHOD, 0, "@Connect"
"BSTR" @hostname, TYPE 8
RETURNING "BSTR", TYPE 8

* [Class: FTPSClient] System.String Connect(System.String, AlexPilotti.FTPS.Client.ESSLSupportMode)
METHOD, 0, "@Connect"
"BSTR" @hostname, TYPE 8
"int" @sslSupportMode, TYPE 3
RETURNING "BSTR", TYPE 8

 

AcuCobol source

 

IDENTIFICATION DIVISION.
PROGRAM-ID. SFTP.
AUTHOR. EB.
DATE-WRITTEN. 01/01/21.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. RMC.
OBJECT-COMPUTER. RMC.

special-names.

COPY "D:\\FTPS\\AlexPilotti.FTPS.Client.DEF"..

DATA DIVISION.
WORKING-STORAGE SECTION.

copy "P:\\AcuCorp\\AcuGT\\sample\\def\\acucobol.def".
copy "P:\\AcuCorp\\AcuGT\\sample\\def\\acugui.def".
copy "P:\\AcuCorp\\AcuGT\\sample\\def\\crtvars.def".
copy "P:\\AcuCorp\\AcuGT\\sample\\def\\controls.def".
copy "P:\\AcuCorp\\AcuGT\\sample\\def\\opensave.def".


77 WS-STATUS PIC 9(04) VALUE 0.
77 WS-STRING PIC X(256) VALUE SPACES.

77 MY-ASSY-HANDLE USAGE IS HANDLE.
77 MY-ASSY-HANDLE-FTPSClient USAGE IS HANDLE.

*----------------------------------------------------------------
PROCEDURE DIVISION.
MAIN-PROG SECTION.
INIT-PARAM.

CREATE "AlexPilotti.FTPS.Client"
            NAMESPACE IS "AlexPilotti.FTPS.Client",
           CLASS-NAME IS "FTPSClient",
           CONSTRUCTOR IS CONSTRUCTOR1(),
                    HANDLE IS MY-ASSY-HANDLE.

 

Can someone help met with the connect statement.
I have to translate ... using (FTPSClient client = new FTPSClient())
But it is not clear for me how.

From here (connect) Undefined data item: FTPSCLIENT

MODIFY MY-ASSY-HANDLE
                       ("ftp.server.com",
                       "ftp_login_naam",
                         "password"
                        ) GIVING WS-STRING.

 

And  how to convert the download

// Download a file
client.GetFile("/path/to/remotefile.jpg", "c:\\\\local\\\\path\\\\");

 

          ENDS.

                  stop run.

 

Hi

I'm sorry but I never used DLL with Cobol.

Since nobody gave you a reply, if you simply need to download a file from an SFTP server, maybe you can use PSFTP. It is a plugin for the free PuTTY client.

Installing it on Windows give you the possibility to download a file from a SFTP server with a single command / batch file.

Finally, you can directly call the command/batch file from Cobol using the C$SYSTEM function

 

I know it is a workaround and not the solution to your question, but I hope it can help you


I am trying to convert a C# sample (ftp from AlexPilotti) to AcuCobol, but the second part is not clear to me.
Maybe someone can help me with this sample.

 

https://archive.codeplex.com/?p=ftps


using AlexPilotti.FTPS.Client;
using AlexPilotti.FTPS.Common;
using System.Net;


class Test
{
    public static void Main()
    {
           using (FTPSClient client = new FTPSClient())
           {
               // Connect to the server, with mandatory SSL/TLS
              // encryption during authentication and
              // optional encryption on the data channel
              // (directory lists, file transfers)
              client.Connect("ftp.yourserver.com",
                               new NetworkCredential("yourUsername",
                                                                                "yourPassword"),
                                ESSLSupportMode.CredentialsRequired |
                                ESSLSupportMode.DataChannelRequested);

               // Download a file
                   client.GetFile("/path/to/remotefile.jpg", "c:\\\\local\\\\path\\\\");
             }
        }
}


Part of NETDEFGEN

 

* FULLY-QUALIFIED-NAME AlexPilotti.FTPS.Client.FTPSClient, AlexPilotti.FTPS.Client, Version=1.1.0.27735, Culture=neutral, PublicKeyToken=48316da1e84b328d

* AlexPilotti.FTPS.Client.FTPSClient
NAMESPACE "AlexPilotti.FTPS.Client"
CLASS "FTPSClient"
MODULE "AlexPilotti.FTPS.Client.dll"
CONSTRUCTOR, 0, @CONSTRUCTOR1

* [Class: FTPSClient] System.String Connect(System.String)
METHOD, 0, "@Connect"
"BSTR" @hostname, TYPE 8
RETURNING "BSTR", TYPE 8

* [Class: FTPSClient] System.String Connect(System.String, AlexPilotti.FTPS.Client.ESSLSupportMode)
METHOD, 0, "@Connect"
"BSTR" @hostname, TYPE 8
"int" @sslSupportMode, TYPE 3
RETURNING "BSTR", TYPE 8

 

AcuCobol source

 

IDENTIFICATION DIVISION.
PROGRAM-ID. SFTP.
AUTHOR. EB.
DATE-WRITTEN. 01/01/21.
ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER. RMC.
OBJECT-COMPUTER. RMC.

special-names.

COPY "D:\\FTPS\\AlexPilotti.FTPS.Client.DEF"..

DATA DIVISION.
WORKING-STORAGE SECTION.

copy "P:\\AcuCorp\\AcuGT\\sample\\def\\acucobol.def".
copy "P:\\AcuCorp\\AcuGT\\sample\\def\\acugui.def".
copy "P:\\AcuCorp\\AcuGT\\sample\\def\\crtvars.def".
copy "P:\\AcuCorp\\AcuGT\\sample\\def\\controls.def".
copy "P:\\AcuCorp\\AcuGT\\sample\\def\\opensave.def".


77 WS-STATUS PIC 9(04) VALUE 0.
77 WS-STRING PIC X(256) VALUE SPACES.

77 MY-ASSY-HANDLE USAGE IS HANDLE.
77 MY-ASSY-HANDLE-FTPSClient USAGE IS HANDLE.

*----------------------------------------------------------------
PROCEDURE DIVISION.
MAIN-PROG SECTION.
INIT-PARAM.

CREATE "AlexPilotti.FTPS.Client"
            NAMESPACE IS "AlexPilotti.FTPS.Client",
           CLASS-NAME IS "FTPSClient",
           CONSTRUCTOR IS CONSTRUCTOR1(),
                    HANDLE IS MY-ASSY-HANDLE.

 

Can someone help met with the connect statement.
I have to translate ... using (FTPSClient client = new FTPSClient())
But it is not clear for me how.

From here (connect) Undefined data item: FTPSCLIENT

MODIFY MY-ASSY-HANDLE
                       ("ftp.server.com",
                       "ftp_login_naam",
                         "password"
                        ) GIVING WS-STRING.

 

And  how to convert the download

// Download a file
client.GetFile("/path/to/remotefile.jpg", "c:\\\\local\\\\path\\\\");

 

          ENDS.

                  stop run.

 

hi !

I believe your error is in using generic handle type.

you sould change

 

77 MY-ASSY-HANDLE USAGE IS HANDLE

into

77 MY-ASSY-HANDLE USAGE IS HANDLE of "@AlexPilotti.FTPS.Client".

also you should define a new handle for  NetworkCredential and do another CREATE as in the C# you use "new".

finally I believe you should have another Connect method overload with 3 parameters: hostname, networkCredential, and SSL support.

 


hi !

I believe your error is in using generic handle type.

you sould change

 

77 MY-ASSY-HANDLE USAGE IS HANDLE

into

77 MY-ASSY-HANDLE USAGE IS HANDLE of "@AlexPilotti.FTPS.Client".

also you should define a new handle for  NetworkCredential and do another CREATE as in the C# you use "new".

finally I believe you should have another Connect method overload with 3 parameters: hostname, networkCredential, and SSL support.

 

Thanks all you for your response.

C$system doesn't really have status control capabilities. This makes it difficult to use.


It looks as if here is no difference between
77 MY-ASSY-HANDLE USAGE IS HANDLE
and
77 MY-ASSY-HANDLE USAGE IS HANDLE of "@AlexPilotti.FTPS.Client".

I think one of my problems is that I have no idea how to translate the
using (FTPSClient client = new FTPSClient ())
to cobol . It seems to me like a sub handle of the main handle. Something like:
MODIFY MY-ASSY-HANDLE Createitem (Client.FTPSClient)
GIVING MY-ASSY-HANDLE-FTPSClient.
(not working)

Perhaps someone has any experience in how to translate the :
using (FTPSClient client = new FTPSClient ()) as a first step to solve this