[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ftp_get to IFS



Sender: "Glenn McClenny" <gmcclenny@xxxxxxxxxxx>

Scott and Werner,

Thanks for your input on this! I really appreciate it.

After reading Scott's email, I'm wondering if I have the right version of ftpapi. I've debugged the program, setting several breakpoints, and here's where the issue is:

In the ftp_get() procedure is this code:
5499  *open the file to retrieve
5500                   eval      wwFD = OpnFile(wwLocal: 'W': p_write:
5501                                         p_close)
5502                   if        wwFD < 0
5503                   return    -1
5504                   endif

After the OpnFile is done, wwFD is -1.

Here's the OpnFile section that causes the problem:
8000                   if        wwType='*FILE' or wwType='*MBR'
8001                                or wwExists = *Off
8002                   if        ParsePath(wwPath: wwLib: wwObj:
8003                                wwTmpMbr: wwTmpType) < 0
8004                   return    -1
8005                   endif
8006                   endif

In the ParsePath procedure, wwPath is the correct path that I specify, and the other parameters are blank.

I didn't see the code that Scott listed in his reply. Something tells me that he's going to yell and me, in a positive way of course, to install the latest version :-)

Glenn.



From: Scott Klement <sk@xxxxxxxxxxxxxxxx>
Reply-To: ftpapi@xxxxxxxxxxxxx
To: ftpapi@xxxxxxxxxxxxx
Subject: Re: ftp_get to IFS
Date: Tue, 24 Jan 2006 11:28:15 -0600 (CST)

Sender: Scott Klement <sk@xxxxxxxxxxxxxxxx>

Hi Glenn,

I'm trying to reproduce this error, and so far have not been able to. Following the code that you sent, I created the following program:

H DFTACTGRP(*NO) BNDDIR('LIBFTP/FTPAPI')

/copy libftp/qrpglesrc,ftpapi_h

     D FileNumber      s             10I 0
     D sess            s             10I 0
     D rc              s             10I 0
     D Incoming        s            256A   dim(50)
     D NumberOfFiles   s             10I 0
     D WorkMessage     s             80A

/free

        sess = ftp_conn( 'ftp.example.com'
                       : 'scott'
                       : 'password' );

        rc = ftp_list(sess : 'I*' : 50 : %addr(Incoming) : NumberOfFiles);
        rc = ftp_binaryMode(sess : *off);

        FileNumber = 1;
        dow FileNumber <= NumberOfFiles;
          rc = ftp_get(sess : Incoming(FileNumber) :
               '/A123456789012345/INVOICES/' +
               %trim(Incoming(FileNumber)));
          WorkMessage = ftp_errorMsg(sess);
          FileNumber += 1;
        enddo;

*inlr = *on;

/end-free

Prior to running this program, I type:

      MKDIR '/A123456789012345'
      MKDIR '/A123456789012345/INVOICES'

I then run the above program -- and it works fine. No errors occur.

Can you tell me how to make it fail?

Are you absolutely certain that the directory name that you picked is typed exactly the same way in your program as it is in the actual filesystem? No typo that would make them slightly different?

In the FTP_Get() subproceure of the FTPAPIR4 service program, you'll find the following code:

C* open a file to receive output
C                   eval      wwFD = open(%addr(wwLocal): O_WRONLY+
C                                     O_TRUNC+O_CREAT+O_CODEPAGE:
C                                     S_IRUSR+S_IWUSR+S_IRGRP+S_IWGRP+
C                                     S_IROTH+S_IWOTH: CP_ASCII)
c                   if        wwFD < 0
c                   callp     geterror(wwErrMsg)
c                   callp     SetError(FTP_OPNERR: wwErrMsg)
c                   return    -1
c                   endif

I suggest setting a breakpoint just after the call to open(). Run it up to that point, and examine the value of "wwLocal". The open() API is part of OS/400 -- so if there's a problem in FTPAPI, the cotnents of wwLocal must be wrong. Otherwise, the problem would be in OS/400, not FTPAPI.

---
Scott Klement  http://www.scottklement.com



On Tue, 24 Jan 2006, Glenn McClenny wrote:

Sender: "Glenn McClenny" <gmcclenny@xxxxxxxxxxx>

This is my first attempt to use ftpapi get files from an ftp site, and I was having an issue with where to put the file.

First, here's my code for the ftp_get routine:

rc = ftp_list(sess : 'I*' : 50 : %addr(Incoming) : NumberOfFiles);
rc = ftp_binaryMode(sess : *off);
FileNumber = 1;
dow FileNumber <= NumberOfFiles;
 rc = ftp_get(sess : Incoming(FileNumber) :
      '/A123456789012345/INVOICES/' +
      %trim(Incoming(FileNumber)));
 WorkMessage = ftp_errorMsg(sess);
 FileNumber += 1;
enddo;

There are 5 files to retrieve from the server, and the Incoming() array has the right file names. When the ftp_get() procedure is issued, I get an error message of "No such path or directory." This path does exist, and I have all access to it.

So, I created another IFS directory off the root, and called it AD. If I changed the path in the ftp_get procedure to AD, it works.

I have double checked my spelling of the original path, and even had somebody else look it over for a spelling mistake (The A123456789012345 isn't really the name of the directory, just a representation of the length of the directory). When I look at the ftpapi source, it would appear that the max length of the file name fo save is 256 including path name.

Just curious as to why I can't place the file in the specified directory. Thanks for your input!

Glenn.


----------------------------------------------------------------------- This is the FTPAPI mailing list. To unsubsribe from the list send mail to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr -----------------------------------------------------------------------

-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------


-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------