Anda di halaman 1dari 13

FTP in AS400

We are using FTP in as400 to send and receive data from/to remote system.

To send/receive files through FTP connection


Below is the procedure to send/receive files through FTP

(1) Start FTP client session by COMMAND 'FTP'

(2) GIVE THE MACHINE USERID AND PASSWORD TO CONNECT TO IT

(3) AFTER THE CONNECTION IS DONE, USE LCD TO CHANGE THE DRIVE AS LOCAL DRIVE

e.g. LCD AMINEM

LCD C:\folder\onpc\where\stuffis

LCD C:\Program Files

(4) PUT COMMEND IS TO SEND THE FILE

e.g. put rpgsrc.GETCL rpgsrc1.GETCL1

RPGSRC1 AND GET1 WILL BE CREATED AUTOMATICALLY.

***If we give the same source file/member name, then the source code will be copied

else we will get only data file for that member which we are sending or receiving.

(5) CD IS TO CHAGE DRIVE OF THE DESTINATION MACHINE

(6) GET COMMAND IS TO GET FILE FROM THE REMOTE SYSTEM

(7) MGET AND MPUT IS USED TO GET AND PUT MULTIPLE FILE, GENERIC IS ALLOWED

e.g. mget aminem.* aminem1.*

(8) QUIT

Below are the basic FTP commands in the transfer:

LCD directory-name
This command is used to change the Local system directory to
directory-name.
e.g.
LCD Library-name
LCD C:\folder\onpc\where\stuffis
LCD C:\Program Files

CD directory-name
This command is used to change the Remote system directory to
directory-name.
e.g.
CD Library-name
CD C:\folder\onpc\where\stuffis
CD C:\Program Files

GET library/source-physical-file. Member-name


This command is used to fetch a file from remote system.
e.g.
GET AMINEM/QRPGLESRC.DSPPGM
This can be used to fetch save-file also:
GET SAV005

If Member SAV005 in file SAV005 in library QGPL already exists.


Specify
REPLACE as a subcommand option as shown below.
GET SAV005 (REPLACE

MGET:
It is used to fetch multiple file from remote system, GENERIC IS
ALLOWED.
e.g.
MGET aminem.* aminem1.*

PUT:
To send a file to remote system
e.g.
PUT RPGSRC.ADDCL RPGSRC11.ADDCL1

MPUT: To send multiple files to remote system


It is used to fetch multiple file from remote system, GENERIC IS

ALLOWED.
e.g.
MGET aminem.* aminem1.*

NAMEFMT (name formatting)

Its value can be 0 or 1, it has been explained below.

QUOTE SITE NAMEFMT 0


For working with standard library objects

File identifiers have three components: Library, File and member.


Library and file components are separated by the / delimiter.

File and member components are separated by the . delimiter.

Syntax: Library/file.member

Example
PUT something.txt QGPL/QCLSRC.TEST

CD QGPL

PUT something.txt QCLSRC.TEST

QUOTE SITE NAMEFMT 1


For working with IFS objects (ie. All objects)

Directory levels separated by the / delimiter.

Database files use format:

/QSYS.lib/Libname.lib/Fname.file/Mname.mbr

Documents (files) stored in folders use format:

/QDLS/folder/document.ext

CD / (puts you in the root IFS folder)

QUIT
Ends the FTP session with the remote computer and exits ftp.

Bye
Ends the FTP session with the remote computer and exits ftp.

ASCII
It Sets the file transfer mode to ASCII (Note: this is the

default mode for most FTP programs)


ASCII is a character-encoding scheme originally based on the

English alphabet. ASCII codes represent text in computers,

communications equipment, and other devices that use text. Most

modern character-encoding schemes are based on ASCII, though they

support many additional characters.

e.g.

ftp> ascii

ftp> put d:\path1\filename1.txt

200 PORT command successful.


Opening ASCII mode data connection for filename1.txt
226 Transfer complete

Binary
It Sets the file transfer mode to Binary

the binary mode transfers all eight bits per byte and must be

used to transfer non-ASCII files or non-standard files e.g. zip

file, tar file, image file, .DAT file, save file, executable

files, sound files, graphic files etc.

e.g.

ftp> binary

ftp> put d:\path1\filename1.zip

200 PORT command successful.

Opening BINARY mode data connection for filename1.zip

Quote
It will send an argument to the remote FTP Server. This statement
is similar in purpose as the "LITERAL" statement.
Site
This parameter is used at the client system to transfer a
function (via the LITERAL or QUOTE statement) to the host site.
e.g.
We can change the naming format to 0 with the command as shown
below.
QUOTE SITE NAMEFMT 0

Open
It opens a new FTP connection with another system.

e.g.

Open system-name

Example- I : Transferring data from one AS400-system to


another AS400-system
File Transfer Protocol

Previous FTP subcommands and messages:


Connecting to host SYSTEM442.HOST123.com at address 10.123.148.241 using port 21.
220-QTCP at SYSTEM442.
220 Connection will close if idle more than 50 minutes.
> IROBO >>>>>> Enter USER NAME here
331 Enter password. >>>>>> Enter PASSWORD here
230 IROBO logged on.
OS/400 is the remote operating system. The TCP/IP version is "V5R3M0".
250 Now using naming format "0".
257 "QGPL" is current library.
> CD AMINEM
250 "AMINEM" is current library.
> LCD AMINEM
Local working directory is AMINEM
> PUT RPGSRC.ADDCL RPGSRC11.ADDCL1
227 Entering Passive Mode (10,123,148,241,231,148).
150 Sending file to member ADDCL1 in file RPGSRC11 in library AMINEM.
250 File transfer completed successfully.

> PUT QCBLLESRC.SRC03A00 QCBLLESRC.SRC03A00


227 Entering Passive Mode (10,123,148,241,209,50).
150 Sending file to member SRC03A00 in file QCBLLESRC in library AMINEM.
250 File transfer completed successfully.
8003 bytes transferred in 0.202 seconds. Transfer rate 39.590 KB/sec.

Example- II : Transferring AS400 objects from one AS400-


system to another AS400-system using save file

To download source member from telnet system SYS5005 SYS4004 Local disk

In System SYS5005 from which the object QRPGLESRC is to be sent, we


do the below steps:
CRTLIB TRANSFER

CRTSRCPF FILE(TRANSFER/QRPGLESRC) RCDLEN(112) Put here all the members required.

CRTSAVF QGPL/SAV005

SAVOBJ OBJ(QRPGLESRC) LIB(TRANSFER) DEV(*SAVF) SAVF(QGPL/SAV005) TGTRLS(V5R4M0)

In System SYS4004 where the object QRPGLESRC is to be restored, we


do the below steps:

CRTSAVF QGPL/SAV005

CRTLIB GETLIB

FTP SYS5005

File Transfer Protocol

Previous FTP subcommands and messages:


Connecting to host SYS5005 at address 164.4.32.67 using port 21.
220-QTCP at SYS5005.IS.SANDVIK.COM.
220 Connection will close if idle more than 5 minutes.
> NAPULIP
331 Enter password.
230 NAPULIP logged on.
OS/400 is the remote operating system. The TCP/IP version is "V7R1M0".
250 Now using naming format "0".
257 "QGPL" is current library.
> BIN
200 Representation type is binary IMAGE.
> GET SAV005
Member SAV005 in file SAV005 in library QGPL already exists.
Specify REPLACE as a subcommand option.
> GET SAV005 (REPLACE
227 Entering Passive Mode (164,4,32,67,172,230).
Enter an FTP subcommand.
> QUIT

===>
------------------------------------------------------------------------------
---------------------------------------------------------------------------------
---
F3=Exit F6=Print F9=Retrieve
F17=Top F18=Bottom F21=CL command line

RSTOBJ OBJ(*ALL) SAVLIB(TRANSFER) DEV(*SAVF) SAVF(QGPL/SAV005) RSTLIB(GETLIB)

*** For save file BIN(binary) command is needed as the savefile cannot be dealt With
default ASCII.

In GETLIB the object QRPGLESRC has been restored. To see the members do,

WRKMBRPDM FILE(GETLIB/QRPGLESRC)

Example- III : Transferring AS400 objects from AS400-system


SYSTEM01to local drive using FTP in batch mode

a) First of all we make a text file FTP001.txt containing below FTP commands.

FTP001.txt

AJAISWAL
AJAISWAL
ASCII
QUOTE SITE NAMEFMT 0
GET AMITCCCC/QRPGLESRC.BIN_EOF EOF.txt
GET AMITCCCC/QRPGLESRC.BIN_INTH INTH.txt
GET AMITCCCC/QRPGLESRC.BIN_MINUTE MINUTE.txt
GET AMITCCCC/QRPGLESRC.BIN_MONTH MONTH.txt
GET AMITCCCC/QRPGLESRC.BIN_MSEC MSEC.txt
QUIT
b) Then we go to CMD and run the command below:

Microsoft Windows [Version 6.1.7601]


Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\ajaiswal>CD C:\Users\ajaiswal\Documents\My data

C:\Users\ajaiswal\Documents\My data>ftp -s:FTP001.txt SYSTEM01


Connected to SYSTEM01.com.
220-QTCP at SYSTEM01.COM.
220 Connection will close if idle more than 5 minutes.
User (SYSTEM01.com:(none)):
331 Enter password.

230 AJAISWAL logged on.


ftp> ASCII
200 Representation type is ASCII nonprint.
ftp> QUOTE SITE NAMEFMT 0
250 Now using naming format "0".
ftp> GET AMITCCCC/QRPGLESRC.BIN_EOF EOF.txt
200 PORT subcommand request successful.
150 Retrieving member BIN_EOF in file QRPGLESRC in library AMITCCCC.
226 File transfer completed successfully.
ftp: 1407 bytes received in 0.02Seconds 87.94Kbytes/sec.
ftp> GET AMITCCCC/QRPGLESRC.BIN_INTH INTH.txt
200 PORT subcommand request successful.
150 Retrieving member BIN_INTH in file QRPGLESRC in library AMITCCCC.
226 File transfer completed successfully.
ftp: 544 bytes received in 0.00Seconds 544000.00Kbytes/sec.
ftp> GET AMITCCCC/QRPGLESRC.BIN_MINUTE MINUTE.txt
200 PORT subcommand request successful.
150 Retrieving member BIN_MINUTE in file QRPGLESRC in library
AMITCCCC.
226 File transfer completed successfully.
ftp: 578 bytes received in 0.00Seconds 578000.00Kbytes/sec.
ftp> GET AMITCCCC/QRPGLESRC.BIN_MONTH MONTH.txt
200 PORT subcommand request successful.
150 Retrieving member BIN_MONTH in file QRPGLESRC in library AMITCCCC.
226 File transfer completed successfully.
ftp: 576 bytes received in 0.00Seconds 576000.00Kbytes/sec.
ftp> GET AMITCCCC/QRPGLESRC.BIN_MSEC MSEC.txt
200 PORT subcommand request successful.
150 Retrieving member BIN_MSEC in file QRPGLESRC in library AMITCCCC.
226 File transfer completed successfully.
ftp: 604 bytes received in 0.00Seconds 604000.00Kbytes/sec.
ftp> QUIT
221 QUIT subcommand received.

C:\Users\ajaiswal\Documents\My data>EXIT

Hence we have received the text files INTH.txt, MINUTE.txt, MONTH.txt, and
MSEC.txt for the as400 objects.

Command-line options

ftp [-d] [-s:filename]

-d - Enables debugging, displaying all ftp commands passed between the client and
server.

-s:filename - Specifies a text file containing ftp commands; the commands will
automatically run after ftp starts. No spaces are allowed in this parameter. Use this switch
instead of redirection (>).
Example IV : Send data from one system to another using
command prompt
In the below example, we are transferring savfile SAV001 from system
SYSTEM01 to system SYSTEM02.

Microsoft Windows [Version 6.1.7601]


Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\ajaiswal>CD DOCUMENTS
C:\Users\ajaiswal\Documents>FTP SYSTEM01
Connected to SYSTEM01.com.
220-QTCP at SYSTEM01.com
220 Connection will close if idle more than 5 minutes.
User (SYSTEM01.com:(none)): AMIT
331 Enter password.
Password:
230 AMIT logged on.
ftp> CD AMITCC
250 "AMITCC" is current library.
ftp> BIN
200 Representation type is binary IMAGE.
ftp> GET SAV001
200 PORT subcommand request successful.
150 Retrieving member SAV001 in file SAV001 in library AMITCC.
226 File transfer completed successfully.
ftp: 1989504 bytes received in 17.39Seconds 114.38Kbytes/sec.
ftp> QUIT
221 QUIT subcommand received.

C:\Users\ajaiswal\Documents>ftp SYSTEM02
Connected to SYSTEM02.com.
220-QTCP at SYSTEM02.COM.
220 Connection will close if idle more than 5 minutes.
User (SYSTEM02.com:(none)): AMIT
331 Enter password.
Password:
230 AMIT logged on.
ftp> bin
200 Representation type is binary IMAGE.
ftp> cd amitccc
250 "AMITCCC" is current library.
ftp> put sav001
200 PORT subcommand request successful.
150 Sending file to member SAV001 in file SAV001 in library AMITCCCC.
226 File transfer completed successfully.
ftp: 1989504 bytes sent in 11.12Seconds 178.86Kbytes/sec.
ftp> QUIT

Example V: Difference b/w NAMEFMT 0 and NAMEFMT 1

In case of namefmt 0

get {library}/{save_file_name}.savf {save_file_name}.savf (replace

In case of namefmt 1

get /qsys.lib/{library}.lib/{save_file_name}.savf {save_file_name}.savf (replace

NAMEFMT 0

Microsoft Windows [Version 6.1.7601]


Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\ajaiswal>CD C:\Users\ajaiswal\Documents\My data

C:\Users\ajaiswal\Documents\My data>FTP SYSTEM01


Connected to SYSTEM01.com.
220-QTCP at SYSTEM01.COM.
220 Connection will close if idle more than 5 minutes.
User (SYSTEM01.com:(none)): AJAISWAL
331 Enter password.
Password:
230 AJAISWAL logged on.
ftp> QUOTE SITE NAMEFMT 0
250 Now using naming format "0".
ftp> GET AMITCCCC/QRPGLESRC.BIN_EOF EOF_NEW.txt
200 PORT subcommand request successful.
150 Retrieving member BIN_EOF in file QRPGLESRC in library AMITCCCC.
226 File transfer completed successfully.
ftp: 1407 bytes received in 0.09Seconds 14.97Kbytes/sec.

NAMEFMT 1
C:\Users\ajaiswal\Documents\My data>FTP SYSTEM01
Connected to SYSTEM01.com.
220-QTCP at SYSTEM01.COM.
220 Connection will close if idle more than 5 minutes.
User (SYSTEM01.com:(none)): AJAISWAL
331 Enter password.
Password:
230 AJAISWAL logged on.
ftp> GET /QSYS.LIB/AMITCCCC.LIB/QRPGLESRC.FILE/BIN_EOF.MBR KKK.txt
200 PORT subcommand request successful.
150-NAMEFMT set to 1.
150 Retrieving member BIN_EOF in file QRPGLESRC in library AMITCCCC.
226 File transfer completed successfully.
ftp: 1407 bytes received in 0.02Seconds 87.94Kbytes/sec.
ftp> quit
221 QUIT subcommand received.

Anda mungkin juga menyukai