[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: TESTPUT
Yeah. I saw that. So what I did was used a CL program to pass the parms.
In addition, in the RPG code, I did this to get rid of all the garbage at the end.
In fact, instead of just posting piecemeal, here's the whole program. It's pretty short.
*****************************************************************
* To Compile:
*
* CRTRPGMOD MODULE(xxx/PUTFILR1) SRCFILE(xxx/FTPAPISRC)
*
* CRTPGM PGM(xxx/PUTFILR1) BNDSRVPGM(LIBFTP/FTPAPIR4) ACTGRP(*NEW)
*
*****************************************************************
‚ H BNDDIR('FTPAPI')
CPY /COPY FTPAPISRC,FTPAPI_H €
D Msg S 52A
D sess S 10I 0
D Apost C Const('''')
D Host S 10A
D UserID S 10A
D Password S 10A
D NULL S 1a Inz(x'00')
*
DCurFilPath S 256A
DRmtFilPath S 256A
DCPath0 S 256A
DRPath0 S 256A
DBinaryMode S n
DNameFmt S 10i 0
D Rz S 5 0
C *Entry Plist
C Parm Host
C Parm UserID
C Parm Password
C Parm CurFilPath
C Parm RmtFilPath
C Parm BinaryMode
C Parm NameFMt
*
* Strip extraneous garbage from paramaters passed in (handles passing in from command line)
C Eval Rz = %Scan(' ':CurFilPath)
C If Rz > 0
C Eval CPath0 = %Subst(CurFilPath:1:Rz - 1)
C Endif
*
C Eval Rz = %Scan(' ':RmtFilPath)
C If Rz > 0
C Eval RPath0 = %Subst(RmtFilPath:1:Rz - 1)
C Endif
‚ * connect to FTP server. If an error occurs,
‚ * display an error message and exit.
c eval sess = ftp_conn(Host:UserID:Password)
B01 c if sess < 0
c eval Msg = ftp_errorMsg(0)
c dsply Msg
c eval *inlr = *on
c return
E01 c endif
‚ * Set transfer mode
c callp ftp_binaryMode(sess: BinaryMode)
* Set Name Format
c callp ftp_namFmt(sess: NameFmt)
* Put the file on the remote server
This ONE DOES NOT WORK
B01 c* if ftp_put(sess:
C* %trim(RPath0):
C* %trim(CPath0)) < 0
THiS ONE WORKS...
B01 c if ftp_put(sess:
C '/QSYS.LIB/SOCKETS.LIB/WORKFILE1.FILE':
C '/QSYS.LIB/SOCKETS.LIB/WORKFILE1.FILE')
c < 0
c eval Msg = ftp_errorMsg(sess)
c dsply Msg
E01 c endif
c callp ftp_quit(sess)
c eval *inlr = *on
c return
Shannon O'Donnell
-----Original Message-----
From: owner-ftpapi@xxxxxxxxxxxxx [mailto:owner-ftpapi@xxxxxxxxxxxxx] On Behalf Of Calabro, Buck
Sent: Thursday, January 20, 2005 1:11 PM
To: ftpapi@xxxxxxxxxxxxx
Subject: RE: TESTPUT
Sender: "Calabro, Buck" <Buck.Calabro@xxxxxxxxxxxx>
> However, when I attempt to use a variable for those paramaters, I
> always get a "No Such File or Directory" error message.
What are the chances that these parms are coming from the command line? If that's the case, you may have garbage at the end of the parameters because you didn't specify at least 256 characters between the apostrophes.
If you're doing
call testput '/dir/dir/dir/file.ext' '/dir/file.ext'
then OS400 will pass the first 32 characters of the literals followed by whatever happens to be following them in memory. (A better explanation is in the FAQ at http://faq.midrange.com Search for 'garbage'.)
Instead try
call testput '/dir/dir/dir/file.ext
' '/dir/file.ext
'
or something equivalent. If you pass enough blanks then your %trim will work because you won't have junk after the part you typed in. One good way to debug that is to either use the debugger and inspect the variables in hex, or use the DUMP opcode.
--buck
The information contained in this electronic mail transmission is intended by Communications Software Consultants, Inc. for the use of the named individual or entity to which it is directed and may contain information that is privileged or otherwise confidential. If you have received this electronic mail transmission in error, please notify the sender immediately and delete this message from your system without copying or forwarding it.
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubsribe from the list send mail to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------
*****************************************************************
* To Compile:
*
* CRTRPGMOD MODULE(xxx/GETFILR1) SRCFILE(xxx/FTPAPISRC)
*
* CRTPGM PGM(xxx/GETFILR1) BNDSRVPGM(LIBFTP/FTPAPIR4) ACTGRP(*NEW)
*
*****************************************************************
? H BNDDIR('FTPAPI')
CPY /COPY FTPAPISRC,FTPAPI_H ?
D Msg S 52A
D sess S 10I 0
D Apost C Const('''')
D Host S 10A
D UserID S 10A
D Password S 10A
D NULL S 1a Inz(x'00')
*
DCurFilPath S 256A
DRmtFilPath S 256A
DCPath0 S 250A
DRPath0 S 250A
DCPath1 S 250A
DRPath1 S 250A
DBinaryMode S n
DNameFmt S 10i 0
D Rz S 5 0
C *Entry Plist
C Parm Host
C Parm UserID
C Parm Password
C Parm CurFilPath
C Parm RmtFilPath
C Parm BinaryMode
C Parm NameFMt
*
C Eval Rz = %Scan(' ':CurFilPath)
C If Rz > 0
C Eval CPath0 = %Subst(CurFilPath:1:Rz - 1)
C Endif
*
C Eval Rz = %Scan(' ':RmtFilPath)
C If Rz > 0
C Eval RPath0 = %Subst(RmtFilPath:1:Rz - 1)
C Endif
C Eval Cpath1 = Apost + %Trimr(Cpath0) + Apost
C Eval Rpath1 = Apost + %Trimr(Rpath0) + Apost
? * connect to FTP server. If an error occurs,
? * display an error message and exit.
c eval sess = ftp_conn(Host:UserID:Password)
B01 c if sess < 0
c eval Msg = ftp_errorMsg(0)
c dsply Msg
c eval *inlr = *on
c return
E01 c endif
? * Change to the directory you want to put to on the remote server
B01 c* if ftp_chdir(sess: '/') < 0
c* eval Msg = ftp_errorMsg(sess)
c* dsply Msg
c** callp ftp_quit(sess)
c* eval *inlr = *on
c* return
E01 c* endif
* Set transfer mode
c callp ftp_binaryMode(sess: BinaryMode)
* Set Name Format
c callp ftp_namFmt(sess: NameFmt)
* Put the file on the remote server
B01 c* if ftp_put(sess:
C* %trim(RPath1) + Null:
C* %trim(CPath1) + Null) < 0
B01 c if ftp_put(sess:
C '/QSYS.LIB/SOCKETS.LIB/WORKFILE1.FILE':
C '/QSYS.LIB/SOCKETS.LIB/WORKFILE1.FILE')
c < 0
c eval Msg = ftp_errorMsg(sess)
c dsply Msg
E01 c endif
c callp ftp_quit(sess)
c eval *inlr = *on
c return