Re: FTPAPI

"stefan-6HgPSzB/[email protected]" <stefan-6HgPSzB/[email protected]>
Newsgroups gmane.comp.lang.as400.rpg
Message-ID <AS8PR08MB9119EF5DDB0221B2FBA4B903FFA8A@AS8PR08MB9119.eurprd08.prod.outlook.com>
Hi Greg., been traveling without my laptop ( known as holidays ) so sorry for the late reply.
In ftpapi there are callback functionality built in for logging , see ftpapi.exitproc.
I've been using it long time ago like:

  for x = 1 to p.ftpcount;
      p.handle( x ) = ftp_open( %trimr( p.ipadress( x )): p.ftpport( x ));
      if p.handle( x ) < 0;
          wxerr = FTP_errorMsg( 0: errnum );
          errtxt = 'Error on ftp_open: ' + %trimr( wxerr ) + ' > ' +
                   %trim( %editc( errnum:'M' )) + ' for ' + %trimr( p.ipadress( x ));
          complain( thisp: errtxt );
          return *on;
      endif;

      // Register exit procedure for logging purposes

      ftp_exitProc( p.handle( x ): FTP_EXTLOG: %paddr('LOGFTPP'): *null );

      // Login to put session

      if ftp_login( p.handle( x ): %trimr( p.account( x )): %trimr( p.password( x )) ) < 0;
          wxerr = FTP_errorMsg( p.handle( x ): errnum ) + ' > ' + %trim( %editc( errnum:'M' ));
          errtxt = 'Error on ftp_login: ' + %trimr( p.account( x )) + ' ' + %trimr( wxerr );
          complain( thisp: errtxt );
          for x = 1 to p.ftpcount;
              ftp_quit( p.handle( x ));
          endfor;
          return *on;
      endif;

      // Set passive mode if specified

      if p.passive( x );
          if ftp_passiveMode( p.handle( x ): *on ) < 0;
              wxerr = FTP_errorMsg( p.handle( x ): errnum ) + ' > ' + %trim( %editc( errnum:'M' ));
              errtxt = 'Error on ftp_passiveMode ' + %trimr( wxerr );
              complain( thisp: errtxt );
              for x = 1 to p.ftpcount;
                  ftp_quit( p.handle( x ));
              endfor;
              return *on;
          endif;
      endif;

      // Force Binary mode for pdf files

      if ftp_binaryMode( p.handle( x ): *on ) < 0;
          wxerr = FTP_errorMsg( p.handle( x ): errnum ) + ' > ' + %trim( %editc( errnum:'M' ));
          errtxt = 'Error on ftp_binaryMode ' + %trimr( wxerr );
          complain( thisp: errtxt );
          for x = 1 to p.ftpcount;
              ftp_quit( p.handle( x ));
          endfor;
          return *on;
      endif;
  endfor;

<------>

// *===============================================================
// * Logftpp   Log ftp events put session                         +
// *===============================================================
  dcl-proc Logftpp;
    dcl-pi Logftpp;
      peMsgTxt               char( 256 )         const;
      peLogFile              int( 10 );
    end-pi;

  dcl-c thisp                'LogFtpP';

  tell( thisp: peMsgTxt: 5 );   ( writes peMsgTxt to a streamfile )

  end-proc;




Best regards



Stefan



--

No trees were killed in the sending of this message, but a large number of electrons were terribly upset.



Stefan Tageson

+46 732 369934

stefan-6HgPSzB/[email protected]<mailto:stefan-6HgPSzB/[email protected]>





________________________________
From: RPG400-L <rpg400-l-bounces-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org> on behalf of Greg Wilburn <gwilburn-kuYYJ3CQfvZxq3Q2jbZZw/[email protected]>
Sent: Tuesday, December 16, 2025 16:16
To: RPG programming on IBM i <[email protected]>
Subject: FTPAPI

I use Scott's LIBFTP (FTPAPI) occasionally instead of an FTP Script when exchanging data.

I would like to have a simple "text" log on the IFS for each FTP session.
With a script, I override OUTPUT to a PF in QTEMP, then using CPYTOIMPF to create the text file.
(As CYA, I typically have DIR or LS in the script before I get and remove files)

With FTPAPI, the logging can go to the joblog by enabling FTP Logging.   So, I'm considering using CPYSPLF to send the entire joblog to the IFS.
Just wondering if anyone has done something similar?

TIA,
Greg
[Logo]<https://www.totalbizfulfillment.com/>    Greg Wilburn
Director of IT
301.895.3792 ext. 1231
301.895.3895 direct
gwilburn-kuYYJ3CQfvZxq3Q2jbZZw/[email protected]<mailto:gwilburn-kuYYJ3CQfvZxq3Q2jbZZw/[email protected]>
1 Corporate Dr
Grantsville, MD 21536
[http://www.totalbizfulfillment.com<http://www.totalbizfulfillment.com>]www.totalbizfulfillment.com<http://www.totalbizfulfillment.com>
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org for any subscription related questions.

-- 
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request-+hD5IHI5Xscn3HwCXmMcX9BPR1lH4CV8@public.gmane.org
Before posting, please take a moment to review the archives
at https://archive.midrange.com/rpg400-l.

Please contact support-FMtJrHiV//lnDLsaKlm4mFaTQe2KTcn/@public.gmane.org for any subscription related questions.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.