FTP refresher part IV - sending and receiving PC files

You can send PC files to the i5 and receive i5 files on the PC. If using windows on the PC, go to the start/run dialog box and type 'cmd'. Change to the directory where either your PC files exist or where you want to store received files.

cd c:\myfiles\test-ftp-data

From the DOS command line start your ftp session. If you connect to the iSeries remotely you may have to start your VPN connection first.

ftp> remote-sys (where remote-sys is either the i5 IP or DNS address, either should work)

ftp starts, connection messages received, log-in required.
Connected to remote-sys.
220 Connection will close if idle more than 5 minutes.
User (remote-sys:(none)):  userID                         (enter your i5 signon userID and password)
331 Enter password.
Password:   (displayed as blanks)
230 user-id logged on.

Set up the pc directory where the file to send exists;
ftp> lcd c:\myfiles\files-to-upload

Next, enter the mode for the transmission.  The mode is 'ascii' for text files and binary (or just 'bin') for data files.
ftp>ascii
200 Representation type is ASCII nonprint.

FTP will not translate packed/zoned data but you can use the command CPYTOIMPF (copy to import file) to unpack the data if receiving from the i5.  This command is very flexible and handles decimal points, delimiters, negative numbers, etc.  It should not be necessary for text files however.

The transmission mode can be verified by typing the 'type' command. This step is optional.
ftp>type
Using ascii mode to transfer files.

Next issue the command to send or receive the files.
To retrieve file(s) from the i5:
ftp> get remote-lib/remote-file.remote-mbr to-pc-file.txt     (the i5 "from file.member" and PC "to file")

Several status messages received...
250 File transfer completed successfully
As well as a message  showing the size of the transferred file and the amount of time the transfer took.

To upload from the PC to the i5 (when uploading I normally create a save file where the target library is QGPL):
ftp> put pc-file-txt remote-lib/remote-file.remote-mbr

When finished type the ftp command:
ftp>quit

Then enter the dos command:
c:\>exit

Conclusion:  This example shows the simple transmission of a text file.  However, ftp is much more robust and can send/receive save files, transmit in binary, handle wildcards and do multiple put/get commands.  The FTP commands can be automated by using a script file (extension ".ftp").