FTP FAQs
FTP FAQs
YOURLIB/FTPSCRIPTS is a AS/400 sourcefile i.e. created with CRTSRCPF Enter the ftp commands in member Script in file YOURLIB/FTPSCRIPTS using SEU or equivalent. Add a member FTPLOG to YOURLIB/FTPSCRIPTS Pgm ClrPfm File(YOURLIB/FTPSCRIPTS) Mbr(FTPLOG) OvrDbf INPUT ToFile(YOURLIB/FTPSCRIPTS) Mbr(SCRIPT) OvrDbf OUTPUT ToFile(YOURLIB/FTPSCRIPTS) Mbr(FTPLOG) Ftp TargetSystem DltOvr INPUT /* The Logfile could now optionally be parsed in a program */ DltOvr OUTPUT EndPgm It is vital to use the names INPUT and OUTPUT which is the only names AS/400 FTP will react on. This is pretty much like stdin and stdout as it is known in the dos/unix world. Checkout the IBM-reference material on this: http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/QB3ANL03/7.11.4
Put C:\YOURPATH\TEXTFILE.CLP YOURLIB/QCLSRC.TEXTMBR Quit This will transfer the Textfile.clp i directory C:\YOURPATH to the member TEXTMBR in Sourcefile QCLSRC in library YOURLIB on the AS/400
bin put /QSYS.LIB/FROMLIB.LIB/FROMSAVF.SAVF /QSYS.LIB/TOLIB.LIB/TOSAVF.SAVF quit Creating the Savefile using a remote command i.e. quote. ftp host qoute "CRTSAVF File(TOLIB/TOSAVF) binary put FROMLIB/FROMSAVF TOLIB/TOSAVF quit
ftp host syscmd "CRTSAVF FILE(TOLIB/TOSAVF) " bin get FROMLIB/FROMSAVF TOLIB/TOSAVF (REPLACE quit
If communicating with a nother AS/400 in binary mode is is often desirable to work in fixed record length. If the targetfile does not exist then FTP will create a file with recordlength of 512.
If communicating between AS/400s use the Struct command ftp Target Struct R Put fromlib/fromfile.frommbr targetlib/targetfile.targetmbr Assuming the targetfile didnt exist alread y then it would have been created with the correct record length
Use (replace after the local filename. Get FROMLIB/FROMFILE.FROMMBR TOLIB/TOFILE.TOMBR (replace
The command: ftp n s:C:\Mypath\MyScript.sess 123.123.123.123 will perform an upload of MyClPgm.clp to Mylib/QclSrc member MyClPgm in Ascii mode The unfortunate effect of this approach is that the password is stored on the PC. Concider the following setup instead.
A batfile ftpx.bat has the following Del temp.txt Echo user %2 %3>>temp.txt Type %4>>temp.txt ftp n s:temp.txt %1 del temp.txt Same example of upload ftpx 123.123.123.123 myuserid mypassword c:\Mypath\MyScript.sess
I can transfer files with FTP but what about programs, Queries etc
Save the objects using SAVOBJ to a savefile, transfer the savefile with FTP and then restore the objects with RSTOBJ.