Showing posts with label FTP command. Show all posts
Showing posts with label FTP command. Show all posts

Monday, 11 March 2013

FTP(Part 10) - FTP in Batch.



Following is a simple FTP job(ftp in batch).

XX00       M0001.EDW.TEST.JCL(TESTSUKU) - 02.07           Columns 00001 00072
Command ===>                                                  Scroll ===> CSR 
****** ***************************** Top of Data ******************************
000001 //TESTSUKU JOB (EWDS),'FTP TEST'                                       
000002 //TESTFTP1 EXEC PGM=FTP,REGION=6144K,                                  
000003 //         PARM='199.145.85.37 (EXIT TIMEOUT 720'                      
000004 //SYSPRINT DD SYSOUT=*                                                 
.JCPA  //OUTPUT   DD SYSOUT=*                                                 
000006 //INPUT    DD *                                                         
000007  M0001 <username>                                                                
000008  jan9th       <password>                                                           
000009  put 'CMN.TEST.BASO.SRC(TEST111A)' 'M0001.test3.src(by14111a)'        
000010  quit                                                                  
****** **************************** Bottom of Data ****************************

REGION=2048K is a minimum requirement. The requirement could increase depending on the block size of the data set being transmitted.
For PARM=, you can specify any parameter that is valid when invoking FTP from your terminal.

You must include the following three DD statements:

SYSPRINT DD: Alternative name for the OUTPUT DD statement. You can use SYSPRINT DD in place of the OUTPUT DD statement.
OUTPUT DD: Specifies the data set where FTP is to place the client messages and server replies generated during the FTP session.
INPUT DD: Specifies the data set where the FTP subcommands to be performed are located.

Any client messages and server replies to the commands you execute appear in the OUTPUT DD data set. The SYSPRINT can contain some additional messages that relate to the execution of your FTP session.

Note: If you do not want your password to be copied to the output file, specify your user ID and password on separate input lines as shown in the above example.

Following example uses GDG as the target dataset.


XX00       M0001.EDW.TEST.JCL(DW646A0U) - 02.07           Columns 00001 00072
Command ===>                                                  Scroll ===> CSR 
****** ***************************** Top of Data ******************************
000001 //TESTSUKU JOB (EWDS),'FTP TEST'                                       
000002 //DW646S04 EXEC PGM=FTP,REGION=6144K,                                  
000003 //         PARM='199.145.85.37 (EXIT TIMEOUT 720'                      
000004 //SYSPRINT DD SYSOUT=*                                                 
.JCPA  //OUTPUT   DD SYSOUT=*                                                  
000006 //INPUT    DD *                                                        
000007  M0001                                                                
000008  jan8th                                                                 
000009  put 'CMN.TEST.BASO.SRC(TEST111A)' 'M0001.src(+1)'                    
000010  quit                                                                  
****** **************************** Bottom of Data ****************************



After successful execution of the job following is what gets displayed in the output:

***************************** Top of Data ******************************
 EZA1736I FTP 199.145.85.37 (EXIT TIMEOUT 720                          
 EZY2640I Using /etc/ftp.data for local site configuration parameters. 
 EZA1450I IBM FTP CS V1R12                                              
 EZA1772I FTP: EXIT has been set.                                      
 EZA1554I Connecting to:   199.145.85.37 port: 21.                     
 220-FTPSERVE IBM FTP CS V1R12 at MVSXX00.MVS.ABC.COM, 15:20:48 on 1453-
 220 Connection will close if idle for more than 5 minutes.            
 EZA1459I NAME (199.145.85.37:M0001):                                 
 EZA1701I >>> USER M0001                                              
 331 Send password please.                                              
 EZA1789I PASSWORD:  <note that password was not displayed>                                                  
 EZA1701I >>> PASS                                                     
 230 M0001 is logged on.  Working directory is "M0001.".             
 EZA1460I Command:                                                     
 EZA1736I  put 'CMN.TEST.BASO.SRC(TEST111A)' 'M0001.src(+1)'          
 EZA1701I >>> SITE FIXrecfm 80 LRECL=80 RECFM=FB BLKSIZE=27920         
 200 SITE command was accepted  < note that implicit SITE command was generated. We can also execute the SITE command explicitly to specify the dataset attributes>                                        
 EZA1701I >>> PORT 199,145,86,233,73,152                               
 200 Port request OK.                                                  
 EZA1701I >>> STOR 'M0001.src(+1)'                                    
 125 Storing data set M0001.SRC.G0001V00                              
 250 Transfer completed successfully.                                  
 EZA1617I 314528 bytes transferred in 0.005 seconds.  Transfer rate 6402
 EZA1460I Command:                                                      
 EZA1736I  quit                                                        
 EZA1701I >>> QUIT                                                     
 221 Quit command received. Goodbye.                                   
**************************** Bottom of Data ****************************


In following example the remote server name is not passed as PARM, instead written as the 1st line on the input dataset

***************************** Top of Data ******************************
//TESTSUKU JOB (EWDS),'FTP TEST'                                       
//DW646S04 EXEC PGM=FTP,REGION=6144K,                                  
//         PARM=' (EXIT TIMEOUT 720'                                   
//SYSPRINT DD SYSOUT=*                                                 
//OUTPUT   DD SYSOUT=*                                                 
//INPUT    DD *                                                        
 MVSXX00.MVS.ABC.COM                                                   
 M0001                                                                
 jan8th                                                                 
 put 'CMN.TEST.BASO.SRC(TEST111A)' 'M0001.src(+1)'                    
 quit                                                                  
**************************** Bottom of Data ****************************



NOte : All the information about FTP and the syntax diagrams are taken from the site http://publib.boulder.ibm.com.
Things are put here in simplified words and Many commands that are not used normally are omitted.
Refer the website http://publib.boulder.ibm.com. in case you need more details.

FTP(part 9) - FTP file transfer commands


FTP file transfer commands

Append
Use the APpend subcommand to append a local data set to a remote host.

>>-APpend--local_data_set--destination_file--------------------><

local_data_set :The name of the data set on your local host to be appended.
destination_file: The name of the file on the remote host to which your data set is appended. If the destination file does not already exist at the remote host, a new file is created.

DELETE
Use the DELETE subcommand to delete a file on the remote host.

Delete filename

GET
Used to copy a file from the remote host to your local host.

>>-Get--foreign_file--+------------+--+------------+-----------><
                      '-local_file-'  '-(--REPLACE-' 

foreign_file: Specifies the name of the file to be retrieved from the remote host.
local_file: Specifies the name of the local file created as a result of the Get subcommand.

If the current local working directory is a PDS, local_file is the name of the member in the PDS.

If the current local working directory is a data set prefix, the local file is a sequential data set with the local_file name appended to the current local working directory. 

If local filename is not specified then the file is created on the local server with same name as that on the remote server.
MDELETE
Used to delete multiple files.

         .--------------. 
         V              | 
>>-MDelete----foreign_file-+-----------------------------------><

foreign_file : Specifies the name of the file to be deleted on the remote host.

Because more than one file can be deleted with the MDelete subcommand, the foreign_fileparameter of the MDelete subcommand can be repeated many times, with each foreign_fileseparated by a blank space.
MGET
Use the MGet subcommand to copy multiple files from a remote host to your local host and create a corresponding number of local files.

         .--------------.                 
         V              |                 
>>-MGet----foreign_file-+--+------------+----------------------><
                           '-(--REPLACE-' 

Foreign_file: Specifies the name of the file to be retrieved from the remote host.

Because more than one file can be copied with the MGet subcommand, the foreign_fileparameter of the MGet subcommand can be repeated many times, with each foreign_fileseparated by a blank space.

You can use special characters for pattern matching when specifying the foreign_file with the MGet subcommand.

Mget abc* à will get all the files starting with abc
MPUT
 MPut subcommand to copy multiple data sets from your local host to the remote host.

         .----------------. 
         V                | 
>>-MPut----local_data_set-+------------------------------------><

Local_data_set: Specifies the name of the file on your local host being sent to the remote host.

Because more than one data set can be copied with the MPut subcommand, thelocal_data_set parameter of this subcommand can be repeated many times, with eachlocal_data_set separated by a blank space.

You can use the asterisk (*) character for pattern matching when specifying the local_data_set with the MPut subcommand.


PUT
 PUt subcommand to copy data sets from your local host to the remote host.

>>-PUt--local_file--+--------------+---------------------------><
                    '-foreign_file-' 

local_file: Specifies the name of the file on your local host being sent to the remote host.
foreign_file: Specifies the name that the delivered data set is given on the remote host. If the foreign_file name is not specified, the foreign_file name is the same as the local_file name.

RENAME
Use the REName subcommand to rename a file, data set

>>-REName--original_name--new_name-----------------------------><




NOte : All the information about FTP and the syntax diagrams are taken from the site http://publib.boulder.ibm.com.
Things are put here in simplified words and Many commands that are not used normally are omitted.
Refer the website http://publib.boulder.ibm.com. in case you need more details.

FTP(part 6) - Working with Directories on remote server


FTP commands for working with directories on the remote host:

CD/CWD
Changes the working directory.

If remote system is Unix:

ftp> cd test
250 CWD command successful.
ftp> pwd
257 "/home/isaacrdo/M0001/test" is current directory.

If remote system is Mainframe:

250 "M0001." is the working directory name prefix.           
EZA1460I Command: cd test                                     
                                                               
EZA1701I >>> CWD test                                         
250 "M0001.TEST." is the working directory name prefix.      
EZA1460I Command:                                             

ON mainframe TEST is the 2nd node below the HLQ M0001.
PWD
Displays the name of the active working directory on the foreign host.

No parameters for this subcommand.

If remote system is Unix:
ftp> pwd
257 "/home/isaacrdo/M0001" is current directory.

If remote system is Mainframe:

EZA1701I >>> PWD                       
257 "'M0001.'" is working directory.  
EZA1460I Command:                      

CDUP
Used as a special case of the CD subcommand to change the working directory to the next higher directory level.

There are no parameters for this subcommand.

If remote system is Unix:

ftp> pwd
257 "/home/isaacrdo/M0001/test" is current directory.
ftp> cdup
250 CWD command successful.
ftp> pwd
257 "/home/isaacrdo/M0001" is current directory.

If remote system is Mainframe:

EZA1460I Command: cd test                                
                                                         
EZA1701I >>> CWD test                                    
250 "M0001.TEST." is the working directory name prefix.  
EZA1460I Command: cdup                                   
                                                         
EZA1701I >>> CDUP                                        
250 "M0001." is the working directory name prefix.      
EZA1460I Command:                                         

MKDIR
Used to create a directory on remote host

 
>>-MKdir--directory--+--------------------------+--------------><
                     '-(--like--local_directory-' 

Directory : Specifies the name of the directory to be created.
local_directory: Specifies the name of a local directory that is to be a model for the remote directory.

If remote system is Mainframe:

250 "M0001." is the working directory name prefix.     
EZA1460I Command: mkdir level3                          
                                                         
EZA1701I >>> MKD level3                                 
257 "'M0001.LEVEL3'" created.                          
EZA1460I Command:                                       

Note that above command will create the PDS with the name M0001.level3 on remote server.

Command ===>                                                  Scroll ===> CSR 
                                                                              
Command - Enter "/" to select action                  Message           Volume
-------------------------------------------------------------------------------
         M0001.LEVEL3                                                  PCH265
***************************** End of Data Set list ****************************


If remote system is Unix:

ftp> mkdir test2
257 MKD command successful.
ftp> cd test2
250 CWD command successful.
ftp> pwd
257 "/home/isaacrdo/M0001/test2" is current directory.


RMDIR
Used to remove a directory / PDS on the remote host

If remote system is Unix:

ftp> rmdir test2
250 RMD command successful.

If remote system is Mainframe:

EZA1460I Command: rmdir level3       
                                     
EZA1701I >>> RMD level3              
250 M0001.LEVEL3 deleted.           
EZA1460I Command:                    

Since M0001 is already my working directory we need not fully qualify the name. this will delete the PDS M0001.level3

DIR
Used to obtain a list of directory entries or a list of files in a file group on the remote host, or a list of the members of the partitioned data set, as well as auxiliary information about the files.

Example:

If remote system is Mainframe:


We cd to M0001.test and then issue a dir command

EZA1460I Command: dir                                                         
                                                                               
EZA1701I >>> PORT 199,145,86,225,155,176                                      
200 Port request OK.                                                          
EZA1701I >>> LIST                                                              
125 List started OK                                                           
EZA2284I Volume Unit    Referred Ext Used Recfm Lrecl BlkSz Dsorg Dsname      
EZA2284I PCP421 3390   1452/11/27  1   15  FB      80  8000  PO  CNTLCARD     
EZA2284I Migrated                                                COBOL        
EZA2284I Migrated                                                COPYBOOK     
EZA2284I PCH123 3390   1452/12/24  1  398  FB      80 23440  PO  CTC          
EZA2284I Migrated                                                CTC1         
EZA2284I Migrated                                                DATA         
EZA2284I Migrated                                                DWTBLBKP     
EZA2284I PCP21B 3390   1453/01/01  1  278  FB      80   800  PO  JCL          
EZA2284I Migrated                                                OBJ          
EZA2284I Migrated                                                OUTPUT       
EZA2284I Migrated                                                PROCLIB      
250 List completed successfully.                                              
EZA1460I Command:                                                            

Note that it has provided all the datasets starting with  M0001.test

If remote system is Unix:

dir
-rw-r-----   1 M0001     isaacrdo   1291675 Feb 15 15:25 test3.txt
-rw-r-----   1 M0001     isaacrdo   1291465 Feb 15 15:31 test4.txt
-rw-r-----   1 M0001     isaacrdo   3114546 Feb 15 15:36 test5.txt
-rw-r-----   1 M0001     isaacrdo   3101928 Feb 15 15:50 test6.txt
-rw-r-----   1 M0001     isaacrdo     77420 Feb 15 15:51 test7.txt
-rw-r-----   1 M0001     isaacrdo   2799592 Feb 15 16:01 test8.csv
-rw-r-----   1 M0001     isaacrdo    196012 Feb 15 16:02 test9.csv
-rw-r-----   1 M0001     isaacrdo      2544 Aug  5  1451 testfile
-rw-r-----   1 M0001     isaacrdo      2501 Aug  5  1451 testfile2
-rw-r-----   1 M0001     isaacrdo   1291675 Feb 15 15:01 text.txt
-rw-r-----   1 M0001     isaacrdo    123955 Feb 15 15:17 text2.txt
-rw-r-----   1 M0001     isaacrdo      1487 Aug  5  1451 unix
226 Transfer complete.
16160 bytes received in 0.34 seconds (45.99 Kbytes/s)

Output is similar to ls –lrt
LS
Used to list only the names of a set of remote files, file group, or directory.

Difference between DIR and LS is that DIR provides detailed information about the data sets under the remote working directory, while LS shows the data set names only.


If remote system is Mainframe:

ls                                             
 EZA1701I >>> PORT 199,145,86,225,161,208      
 200 Port request OK.                          
 EZA1701I >>> NLST                             
 125 List started OK                           
 EZA2284I CNTLCARD                             
 EZA2284I COBOL                                
 EZA2284I COPYBOOK                              
 EZA2284I CTC                                  
 EZA2284I CTC1                                 
 EZA2284I DATA                                 
 EZA2284I DWTBLBKP                             
 EZA2284I JCL                                   
 EZA2284I OBJ                                  
 EZA2284I OUTPUT                               
 EZA2284I PROCLIB                              
 250 List completed successfully.              
 EZA1460I Command:                             
                                                
If remote system is unix:

text2.txt
test3.txt
test4.txt
test5.txt
test6.txt
test7.txt
test8.csv
test9.csv
226 Transfer complete.
5141 bytes received in 0.03 seconds (164.83 Kbytes/s)





NOte : All the information about FTP and the syntax diagrams are taken from the site http://publib.boulder.ibm.com.
Things are put here in simplified words and Many commands that are not used normally are omitted.
Refer the website http://publib.boulder.ibm.com. in case you need more details.