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

SV: TESTPUT w. var. for local path frequently returns "No such path ordirectory lists



   Hi,

   when "normal" sbmjob fails, i have used sbmjob and RQSDTA:
   Example:

   SBMJOB     JOB(MAIL) JOBQ(QBATCH) RQSDTA('CALL PRX900C +
                PARM(''' *TCAT &PAADR1 *CAT ''' ''' *CAT +
                &PAADR2 *CAT ''' ''' *CAT &PXPDF *CAT +
                ''' ''' *CAT &SUBJECT *CAT ''' ''' *CAT +
                &MAILBODY *CAT ''')')



   This approach works for me.

   Best regards,

   Magne
     _________________________________________________________________

   Fra: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx på vegne av Morten Ju
   Hansen
   Sendt: ma 31.01.2011 12:22
   Til: ftpapi@xxxxxxxxxxxxxxxxxxxxxx
   Emne: TESTPUT w. var. for local path frequently returns "No such path
   ordirectory lists

   Hi Scott.
   It works fine using your corrections to my program.
   Thanks a lot for helping me out of that.
   Morten
   Morten Ju Hansen
   IT-udvikling
   IT Development
   ____________________________________________
   KODA
   Landemærket 23-25
   Postboks 2154
   DK-1016 København K
   T:  +45 33 30 63 84
   F:  +45 33 30 63 30
   mjh@xxxxxxx | www.koda.dk
   ____________________________________________
   Message: 1
   Date: Fri, 28 Jan 2011 12:02:16 -0600
   From: Scott Klement <sk@xxxxxxxxxxxxxxxx>
   Subject: Re:
   "
   To: ftpapi@ TESTPUT w. var. for local path frequently returns "No
           such path       or      directory lists.scottklement.com
   Message-ID: <4D4304A8.8040502@xxxxxxxxxxxxxxxx>
   Content-Type: text/plain; charset=ISO-8859-1; format=flowed
   Hello,
   When you pass a parameter as a literal from CL or the command-line,
   it's
   assumed to be TYPE(*CHAR) LEN(32). When you code a literal longer than
   32 chars, it assumes the variable should be the exact length of your
   literal.
   This is what you have in your CL program:
          CALL       PGM(LIBFTP/TESTPUTMJH) +
                     PARM('ndisfiles/prod/society/063/S063376.zi+
                     p')
   So what it's passing to TESTPUTMJH is a char variable that's defined
   as
   LEN(38) (because your path is 38A).
   When FTPAPI receives it, however, it's received into a 256 byte char
   field.
   Let's say (for the sake of understanding) your variable is placed in
   yoru computer's memory banks at memory address 1000.  That means that
   your 38A variable occupies memory positions 1000-1037.  Anything from
   1038 upwards might be used for other variables in your application, or
   might be unused space that the OS hasn't yet assigned to anything.
   The problem is, FTPAPI is looking at positions 1000-1255.  That's 218
   bytes of memory that might belong to some other variable on the
   system!
     And might contain characters that aren't part of your filename.  The
   result?  Sometimes it works (if you're "lucky" and the memory is
   unused)
   and sometimes it doesn't.
   Note that it's purely coincidence that FTPAPI is involved in this
   case.
     This problem can happen with ANY program call on IBM i where a
   literal
   is used for something larger than 32 chars.
   in your case, the easiest solution is probably to control the variable
   that's passed to the RPG like this:
   PGM
        DCL VAR(&FILE) TYPE(*CHAR) LEN(256)
        CHGVAR VAR(&FILE) +
               VALUE('ndisfiles/prod/society/063/S063376.zip')
        CALL   PGM(LIBFTP/&FILE)
   ENDPGM
   In this case, you've told it how large the variable should be, so that
   won't be a problem.  (However, it'll still fail if you use SBMJOB)
   On 1/28/2011 4:49 AM, Morten Ju Hansen wrote:
   >
   >     Hello everybody.
   >
   >
   >     I think the FTPAPI looks like a fine piece of sottware.
   >
   >
   >     -but having debugged my own version TESTPUTMJH, of TESTPUT, as
   well as
   >     browsing the archives I have come to the of my wits.
   >
   >
   >     TESTGET works great.
   >
   >     I get the fips.exe right on spot whenever I try.
   >
   >
   >     TESTPUT, modified with hardcoded servername/user/password for
   our
   >     remote server, puts always the fips.exe right on.
   >
   >
   >     Got practically no experience with FTP nor coding RPG, so I
   started
   >     with small ambitions:.
   >
   >     TESTPUTMJH, my version of TESTPUT (Please see code enclosed at
   end of
   >     mail)
   >
   >     CL program TSPUTMJHCL (code also enclosed) for calling
   TESTPUTMJH and
   >     not having to write the path for my local testfile all the time.
   >
   >
   >     Whether I call TESTPUTMJH directly or indirectly by calling
   TSPUTMJHCL
   >     I more often than not receive the error message "No such path or
   >     directory.". When debugging with STRDBG it goes wrong here:
   >
   >     FTP_put
   >
   >     .
   >
   >     .
   >
   >     eval      wwFD = OpnFile(wwLocal: 'R': p_read:
   >
   >                           p_close: peSocket)
   >
   >     .
   >
   >     .
   >
   >     FYI wwFD contains -1 when it fails at my place.
   >
   >
   >     Curiously to me the statement `eval      wkTotBytes =
   >     lclFileSiz(wwLocal)' just two lines above ALWAYS returns the
   filesize
   >     correctly.
   >
   >
   >     -but sometimes it all work.
   >
   >     When entering i5/OS Main Menu and CALL TSPUTMJHCL I most often
   get "No
   >     such path or directory." and then it goes wrong no matter how
   many
   >     times I try.
   >
   >
   >     STRPDM, WRKSPLF or Entering STRISDB and leaving ISDB sometimes
   make it
   >     execute correctly when called from a command line one of those
   places.
   >
   >
   >     When debugging it looks to me as wwLocal, p-read, p_close and
   peSocket
   >     always contains the same values before executing
   >
   >     eval      wwFD = OpnFile(wwLocal: 'R': p_read:
   >
   >                           p_close: peSocket)
   >
   >
   >     The path supplied in wwLocal is NEVER enclosed in quotes nor
   >     apostrophes.
   >
   >     I have seen it work with the path
   >
   >     ndisfiles/prod/society/063/S063376.zip
   >
   >     and also with this
   >
   >     /ndisfiles/prod/society/063/S063376.zip
   >
   >     -      As well as failing with either.
   >
   >
   >     So far I have not succeeded when submitting TSPUTMJHCL
   >
   >
   >     Thanks for reading and wishing you all a great weekend.
   >
   >
   >     Morten
   >
   >
   >     CL code for TSPUTMJHCL:
   >
   >
   >     PGM
   >
   >
   >
   >            /*    CHDIR      DIR(/)        */
   >
   >            /*    CHDIR      DIR('NDISFILES/PROD/SOCIETY/063')     */
   >
   >                  DSPCURDIR
   >
   >
   >
   >                  CALL       PGM(LIBFTP/TESTPUTMJH) +
   >
   >
   PARM('ndisfiles/prod/society/063/S063376.zi+
   >
   >                               p')
   >
   >     ENDPGM
   >
   >     ****************** End of data
   >     ****************************************
   >
   >
   >     Code for TESTPUTMJH
   >
   >
   >     0062.00
   >
   >     0063.00 H BNDDIR('FTPAPI') DFTACTGRP(*NO)
   >     ACTGRP(*NEW)
   >
   >     0064.00
   >
   >     0065.00  /COPY QRPGLESRC,FTPAPI_H
   >
   >     0066.00
   >
   >     0067.00 D Msg             S
   >     52A
   >
   >     0068.00 D sess            S             10I
   >     0
   >
   >     0069.00 D Homedirfil      S
   >     256A
   >
   >     0072.00
   >
   >     0073.00 c     *entry
   >     plist
   >
   >     0074.00 c                   parm
   >     Homedirfil
   >
   >     0075.00  * connect to FTP server.  If an error
   >     occurs,
   >
   >     0076.00  *  display an error message and
   >     exit.
   >
   >     0077.00 c                   eval      sess = ftp_conn('X.X.X':
   >
   >     0078.00 c                                        'X':
   >
   >     0079.00 c                                        'X')
   >
   >     0080.00 c                   if        sess<
   >     0
   >
   >     0081.00 c                   eval      Msg =
   >     ftp_errorMsg(0)
   >
   >     0082.00 c                   dsply
   >     Msg
   >
   >     0083.00 c                   eval      *inlr =
   >     *on
   >
   >     0084.00 c                   return
   >
   >     0085.00 c                   endif
   >
   >     0086.00
   >
   >     0087.00  * Change to the CRD_test directory on
   >
   >     0088.00  *  this FTP server.  Deal with any errors.
   >
   >     0089.00 c                   if        ftp_chdir(sess:
   'CRD_test')<  0
   >
   >     0090.00 c                   eval      Msg = ftp_errorMsg(sess)
   >
   >     0091.00 c                   dsply                   Msg
   >
   >     0092.00 c                   dsply                   Msg
   >
   >     0093.00 c                   callp     ftp_quit(sess)
   >
   >     0094.00 c                   eval      *inlr = *on
   >
   >     0095.00 c                   return
   >
   >     0096.00 c                   endif
   >
   >     0097.00
   >
   >     0098.00
   >
   >     0099.00  * put the file specified in Homedirfil
   >
   >     0101.00 c                   callp     ftp_binaryMode(sess: *on)
   >
   >     0102.00 c                   if        ftp_put(sess:
   'S063376.zip':
   >
   >     0103.00 c                                     Homedirfil)<  0
   >
   >     0104.00 c                   eval      Msg = ftp_errorMsg(sess)
   >
   >     0105.00 c                   dsply                   Msg
   >
   >     0106.00 c                   dsply                   Msg
   >
   >     0107.00 c                   dsply                   Msg
   >
   >     0108.00 c                   endif
   >
   >     0109.00
   >
   >     0110.00 c                   callp     ftp_quit(sess)
   >
   >     0111.00 c                   eval      *inlr = *on
   >
   >     0112.00 c                   return
   >
   >
   >     Morten Ju Hansen
   >     IT-udvikling
   >
   >     IT Development
   >
   ------------------------------
   ----------------------------------------------------------------------
   -
   This is the FTPAPI mailing list digest.  To unsubscribe, go to:
   [1]http://www.scottklement.com/mailman/listinfo/ftpapi
   ----------------------------------------------------------------------
   -
   End of Ftpapi Digest, Vol 55, Issue 26
   **************************************
   ______________________________________________________________________
   This email has been scanned by the MessageLabs Email Security System.
   For more information please visit [2]http://www.messagelabs.com/email
   ______________________________________________________________________
   ----------------------------------------------------------------------
   -
   This is the FTPAPI mailing list.  To unsubscribe, please go to:
   [3]http://www.scottklement.com/mailman/listinfo/ftpapi
   ----------------------------------------------------------------------
   -

References

   1. http://www.scottklement.com/mailman/listinfo/ftpapi
   2. http://www.messagelabs.com/email
   3. http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------