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

Monday, 11 March 2013

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.

FTP(Part 1) - FTP command


The FTP command runs the FTP client program that enables you to transfer data sets and files between your local host and another host running an FTP server.

To access FTP we can use any of the following techniques

1)Code PGM=FTP in a batch job and pass parameters using the PARM keyword. This technique is mainly used on the Mainframe systems.
2)Enter the FTP command from TSO.(mainframe)
3)Enter the FTP command from Unix shell or from windows command prompt.


FTP syntax:

Following is the FTP syntax.
Not all the options will be explained here.
The ones that will be generally used are highlighted.

        .----------------------------. 
        V                            | 
>>-ftp----+------------------------+-+-------------------------->
          +- -a-+- NEVER--+--------+   
          |     +- GSSAPI-+        |   
          |     '- TLS----'        |   
          +- -d--------------------+   
          +- -e--------------------+   
          +- -f-- ftpdata_filename-+   
          +- -g--------------------+   
          +- -i--------------------+   
          +- -n--------------------+   
          +- -p-- tcpip------------+   
          +- -r-+- NEVER--+--------+   
          |     +- GSSAPI-+        |   
          |     '- TLS----'        |   
          +- -s-- srcip------------+   
          +- -t-- data_set_name----+   
          +- -v--------------------+   
          +- -w-- nn---------------+   
          '- -x--------------------'   

>--+---------------------------------+-------------------------->
   |                .-21-----------. | 
   '- foreign_host--+--------------+-' 
                    '- port_number-'   

>--+----------------------------------------------------------------------+-->
   '-(--+--------------+--+--------+--+---------------+--+--------------+-' 
        +- Exit--------+  '- TRACe-'  '- TImeout-- nn-'  '- TCP-- tcpip-'   
        '- Exit--=--nn-'                                                    

>--+----------------------------+------------------------------><
   '- TRANslate-- data_set_name-' 


Following is the meaning of parameters we pass:

-d
Starts the generation of tracing output. Equivalent to TRACE.

-e
Terminates FTP for certain FTP errors with a nonzero MVS™ return code. Equivalent to EXIT.

-f ftpdata_filename
Specifies the client file containing the ftp parameters to be used.

-i
Turns off interactive prompting for MDELETE, MGET, and MPUT subcommands. Equivalent to the PROMPT subcommand.Normally when using mget,mput we get a prompt for every file being transferred.

-p tcpip
Indicates the name of the TCP on the local host to which the FTP client should connect. This parameter is ignored if your system is not configured for multiple instances of TCP/IP. This is equivalent to TCP tcpip.

-t data_set_name
Specifies the name of a nonstandard translation table. Equivalent to TRANSLATE data_set_name.

-v
Enables verbose mode. This parameter gives you extra information.

foreign_host
Specifies the name of the host to which you are connecting. Specify the host by its host name or its IP address.  Note that its not compulsory to provide the foreign_host in the ftp command. We can just invoke FTP by typing FTP and then connecting to the server using the OPEN command

port_number
Specifies the port number of the FTP server on the remote host. The default is well-known port 21. The maximum port number that can be specified is 65 534. This parameter should not be used unless you are sure there is a server listening on a port other than the well-known port 21 at the destination.

Exit
Terminates FTP, for certain FTP errors, with a nonzero MVS return code.

Exit=nn
Terminates FTP with a nonzero return code of your choice when an FTP error occurs. Valid values are in the range 0 - 4095.

TRACe
Starts the generation of tracing output. TRACe is used in debugging.

TImeout nn
Specifies the number of seconds (nn) to be used for the following TImeout parameters:
 
MYOPENTIME
DCONNTIME
CCONNTIME
INACTTIME
DATACTTIME

TRANslate data_set_name
Specifies the data set name of a nonstandard translation table.


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.