0% found this document useful (0 votes)
65 views

FTP FAQs

The document provides instructions for running FTP commands in batch mode on an AS/400 system by placing commands in a source file member and running a program. It also provides examples of using FTP to transfer different file types between a PC and AS/400 including text files, source members, save files, and physical files.

Uploaded by

Maran Ganapathy
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views

FTP FAQs

The document provides instructions for running FTP commands in batch mode on an AS/400 system by placing commands in a source file member and running a program. It also provides examples of using FTP to transfer different file types between a PC and AS/400 including text files, source members, save files, and physical files.

Uploaded by

Maran Ganapathy
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

How do I run FTP in batch?

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

How can I test my FTP command without a communication line?


Try to use: FTP loopback This will start a session where the remote machine is actually the local AS/400

How do i transfer a textfile from my PC to an AS/400 sourcefile?


PCFile: C:\YOURPATH\TEXTFILE.CLP Open host Ascii

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

How do I transfer a sourcemember from AS/400 to my PC?


PCFile: C:\YOURPATH\TEXTFILE.CLP Open host Ascii get YOURLIB/QCLSRC.TEXTMBR C:\YOURPATH\TEXTFILE.CLP Quit This will transfer the sourcemember TEXTMBR in sourcefile QCLSRC in library YOURLIB to Textfile.clp in directory C:\YOURPATH.

How do I transfer to/from a specific member on the AS/400?


An example of a put: Put c:\frompath\pcfile.ext YOURLIB/YOURFILE.YOURMEMBER This will transfer the file pcfile.ext in directory c:\frompath to member YOURMEMBER in file YOURFILE in Library YOURLIB. An example of get: Get YOURLIB/YOURFILE.YOURMEMBER c:\topath\tofile.ext This will transfer the member YOURMEMBER in File YOURFILE in Library YOURLIB to the file tofile.ext in directory c:\topath

How do i transfer a savefile with FTP? From local AS/400 to AS/400


Transfering Savefile FROMLIB/FROMSAVF to savefile TOLIB/TOSAVF Assuming that the target savefile does not exist. ftp host namefmt 1

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

From remote AS/400 to local AS/400


Getting Savefile FROMLIB/FROMSAVF to savefile TOLIB/TOSAVF ftp host namefmt 1 bin get /QSYS.LIB/FROMLIB.LIB/FROMSAVF.SAVF /QSYS.LIB/TOLIB.LIB/TOSAVF.SAVF (REPLACE quit

ftp host syscmd "CRTSAVF FILE(TOLIB/TOSAVF) " bin get FROMLIB/FROMSAVF TOLIB/TOSAVF (REPLACE quit

Convert a savefile to a PF using FTP


CrtPf MYLIB/MYPF RCDLEN(528)

FTP LOOPBACK bin Put MYLIB/MYSAVF MYLIB/MYPF Quit

Convert a pf to a savefile using FTP


CrtSavf MYLIB/MYSAVF FTP loopback Bin Get MYLIB/MYPF MYLIB/MYSAVF (Replace Quit

Download from AS/400 to PC


Download the savefile FROMLIB/FROMSAVF to file tofile in directory c:\topath On the PC ftp host bin get FROMLIB/FROMSAVF c:\topath\tofile quit

Upload to AS/400 from PC


Upload the file fromfile in directory c:\frompath to Savefile TOLIB/TOSAVF Creating the savefile first if it doesnt exist using quote On the PC ftp host bin

quote "CRTSAVF File(TOLIB/TOSAVF" put c:\frompath\fromfile TOLIB/TOSAVF quit

Transferring between file systems on the AS/400


FTP on the AS/400 can transfer between the different filesystem ,Qopensys, QDLS, Qroot and the default filesystem. This is done with the FTP-command Namefmt or NM for short A file in library filesystem is in namefmt 1 called, File YOURLIB Library YOURFILE Member YOURMEMBER Will be the following in IFS terms /QSYS.LIB/YOURLIB.LIB/YOURFILE.FILE/YOURMEMBER.MBR A file in Officevision is in the QDLS filesystem Assume that you have a document YOURDOC.XYZ in folder YOURFLR in officevision. The name of this will in IFS terms be: /QDLS/YOURFLR/YOURDOC.XYZ So transfering file(YOURLIB/YOURFILE) Mbr(YOURMEMBER) to document TODOC.XYZ in folder YOURFLR would in FTP could be done with FTP target Namefmt 1 Put /QSYS.LIB/YOURLIB.LIB/YOURFILE.FILE/YOURMEMBER.MBR /QDLS/YOURFLR/TODOC.XYZ Quit

My outputfile doesnt have the correct recordlength.

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

Im doing a get but the file isnt replaced

Use (replace after the local filename. Get FROMLIB/FROMFILE.FROMMBR TOLIB/TOFILE.TOMBR (replace

I cant find the FTP-user guide in IBMs library


The FTP-guide is part of TCP/IP TCP/IP Configuration and Reference: SC41-5420 http://publib.boulder.ibm.com/cgi-bin/bookmgr/DOCNUM/SC41-5420-03 Currently V4R4 it is in chapter 7.

How do I automate uploads/downloads from my PC.


Make a Scriptfile with the FTP-commands to execute. Start the FTP command with ftp n s:ScriptFile host The n command turns prompting for userid and password off. An example The file MyScript.sess in directory MyPath has the following contents: User myuserid mypassword. Ascii Put MyClPgm.clp MyLib/QCLSRC.MyClPgm Quit

Assuming the host is ip-adress 123.123.123.123.

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.

Scriptfile.sess contains. Ascii Put MyClPgm.clp MyLib/QCLSRC.MyClPgm Quit

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.

You might also like