Skip to main content  
        iSeries home   |   Easy400     |   CGIDEV2     |   MMAIL  
Public-Source
 
Introduction
Command set 1
 Command Set 2
Appendix A
Appendix B
 Download
 
 

 
ZIP & UNZIP command set 2

This set is based on Qshell command Jar (Java Archive Tool) created by ORACLE (see this page).

Appendix B shows how to use this command in the Qshell environment.

Our utility includes three CL commands based on "jar" (ZIP2, DSPZIP2 and UNZIP2) to work with zip files.

1 - Command ZIP/ZIP2

                              Zip with "jar" (ZIP2)
                                                                                
 Type choices, press Enter.

 Zip stream file  . . . . . . . . ZIPFILE  /tmp/zipFile1.zip                        
                             
 IFS objects to be zipped . . . . IFSOBJS  /zip/test/a.txt                          
                             
                       + for more values   /zip/css                                 
                             
 Include object paths . . . . . . PATHS    *NO           *YES, *NO
 Output messages  . . . . . . . . OUTPUT   *NONE         *, *PRINT, *NONE
Figure 1 - Command ZIP2

Use this command to compress into a zip file up to 50 IFS objects (stream files and/or directories).
This is done through the QShell "jar" command.

  • Zip stream file (ZIPFILE) - Path and name of the zip stream file that will contain the zipped (compressed) IFS object instances.
    Note 1: The total amount of data to be compressed can be larger than 2 Gigabyte.
    Note 2: This stream file does not have to exist. If already existing, it is deleted and re-created.
    Note 3: This stream file is always assigned CCSID 819 (ASCII).
  • IFS objects to be zipped (IFSOBJS) - Up to 50 IFS objects to be compressed. An IFS object path & name cannot exceed 500 characters.
    Note 4: The compressed (zipped) stream files instances in the zip file are always assigned CCSID 819 (ASCII) by the Qshell "jar" command.
    Command UNZIP2 command provides a TGTCCSID parameter to re-assign their original CCSID's to the unzipped stream files.
    Note 5: Generic names - ending with an asterisk (*) - are not supported.
  • Include stream file paths (PATHS) - Whether the zipped instance of a stream file
    (example:/zip/test/a.txt) should include the stream file file without its path
    (example: a.txt) or with its path
    (example: /zip/test/a.txt).
    In the first case (stream file zipped without path) the stream file will be unzipped as /a.txt.
    In the second case (stream file zipped with path) the stream file will be unzipped as /zip/test/a.txt..
    Note 6: Qshell "jar" command - unlike Qshell command "zip" has no options for suppressing the path of a stream file. Therefore, when command ZIP2 specifies PATHS(*NO), the program has to temporarily copy each stream file in the IFS root ("/") directory (unless that stream file is in the root directory). Before performing the copy operation, the program checks if a stream file with the same name already exists in the root directory. If so, the program sends an error message and stops execution.
    Note 7: If the object to be compressed is a directory, parameter PATHS(*NO) has no effect and the directory is compressed (with all its subdirectories and stream files) as if PATHS(*YES) were specified.

    Select

    • *NO not to include stream file paths
    • *YES to include the stream file paths.
  • Output messages (OUTPUT) - Whether and how the Qshell "jar" output messages should be displayed.
    Select one of the following:
    • * - If the command is running in an interactive job, display output messages on the screen, otherwise display them on a printout named QSYSPRT.
    • *PRINT - Display output messages on a printout named QSYSPRT.
    • *NONE - Do not display output messages.

Note 8: Qshell command "iar" does not support encryption.

Examples:
1.Command  ZIP2 ZIPFILE('/tmp/zipFile1.zip') IFSOBJS('/zip/test/a.txt' '/zip/css')
  PATHS(*NO) OUTPUT(*)

  1. returns the following output messages:
    adding: a.txt(in = 64) (out= 63)(deflated 1%)                  
    adding: zip/css/(in = 0) (out= 0)(stored 0%)                   
    adding: zip/css/css.css(in = 44091) (out= 5027)(deflated 88%)  
    adding: zip/css/cssprint.css(in = 332) (out= 141)(deflated 57%)
  2. Zip file /tmp/zipFile1.zip, once unzipped, inflates the following objects:
    a.txt
    /zip/css
    /zip/css/css.css
    /zip/css/cssprint.css
2. Command  ZIP2 ZIPFILE('/tmp/zipFile2.zip') IFSOBJS('/zip/test/a.txt' '/zip/css')
  PATHS(*YES) OUTPUT(*)
  1. returns the following output messages:
    adding: zip/test/a.txt(in = 64) (out= 63)(deflated 1%)                  
    adding: zip/css/(in = 0) (out= 0)(stored 0%)                   
    adding: zip/css/css.css(in = 44091) (out= 5027)(deflated 88%)  
    adding: zip/css/cssprint.css(in = 332) (out= 141)(deflated 57%)
  2. Zip file /tmp/zipFile2.zip, once unzipped, inflates the following objects:
    /zip/test/a.txt
    /zip/css
    /zip/css/css.css
    /zip/css/cssprint.css

2 - Command ZIP/DSPZIP2

                        Contents of a .zip stmf (DSPZIP2)

 Type choices, press Enter.

 Zip stream file  . . . . . . . . ZIPFILE  /tmp/zipFile1.zip                         
                             
 Output messages  . . . . . . . . OUTPUT   *                    *, *PRINT
Figure 2 - Command DSPZIP2

Use this command to display the contens of a zip stream file.

  • Zip stream file (ZIPFILE) - Path and name of the zip file to be displayed.
  • Output messages (OUTPUT) - Whether and how the Qshell "jar" output messages should be displayed.
    Select one of the following:
    • * - If the command is running in an interactive job, display output messages on the screen, otherwise display them on a printout named QSYSPRT.
    • *PRINT - Display output messages on a printout named QSYSPRT.
    • *NONE - Do not display output messages.

Examples:
1.Command  DSPZIP2 ZIPFILE('/tmp/zipFile1.zip') OUTPUT(*)

  • returns the following output messages:
        64 Sat Sep 23 17:43:58 UTC 2017 a.txt                
         0 Sun Sep 24 13:30:32 UTC 2017 zip/css/             
     44091 Sun Sep 24 13:21:18 UTC 2017 zip/css/css.css      
       332 Sun Sep 24 13:21:20 UTC 2017 zip/css/cssprint.css


3 - Command ZIP/UNZIP2

                        Unzip a ZIP stream file (UNZIP2)

 Type choices, press Enter.

 ZIP stream file  . . . . . . . . ZIPFILE   /tmp/zipFile1.zip                        
                             
 Target directory . . . . . . . . TGTDIR    /mydir                                   
                             
 CCSID of unzipped files  . . . . TGTCCSID  *JOB       Number, *JOB, *SAME
 Display the target directory . . DSPTGTDIR *NO        *BEFORE, *AFTER, *BEFAFT, *NO
 Output messages  . . . . . . . . OUTPUT    *          *, *PRINT, *NONE
Figure 3 - Command UNZIP2

Use this command to unzip a zip stream file.

  • Zip stream file (ZIPFILE) - Path and name of the zip file to be displayed.
  • Target directory (TGTDIR) - IFS directory where the zipped IFS objects will be decompressed.
    Note 1: If a zipped object includes its path, this path is added to the TGTDIR directory. Missing subdirectories are automatically created.
    Note 2: A zipped object always replaces an already existing object in the same path.
  • CCSID of unzipped files (TGTCCSID) - All the zipped stream files are assigned CCSID 819 (ASCII), though their data are kept in the original CCSID's.
    This is why the user of this command is requested to specify a CCSID to be re-assigned to all the zipped stream files after they have been inflated.
    Note 3. The command used to re-assign a CCSID to a stream file without changing its data is like the following:
    CPY OBJ('/tmp2/a.txt') TOOBJ('/tmp2/a.txt') TOCCSID(37) REPLACE(*YES) OWNER(*KEEP)
    Select one of the following:
    • *JOB - Assign the default CCSID of the current job.
    • *SAME - The CCSID of the file is not changed (to be used when the zipped stream file is really a PC file).
    • ccsid value - Enter a CCSID value (range: 37 to 65535).
  • Display the target directory (DSPTGTDIR) - Whether and when the target directory will be displayed (interactive jobs only).
    Select one of the following:
    • *NO - Do not display the target directory.
    • *BEFORE - Display it before the unzip takes place.
    • *AFTER - Display it after the unzip.
    • *BEFAFT - Display it before and after the unzip.
  • Output messages (OUTPUT) - Whether and how the Qshell "jar" output messages should be displayed.
    Select one of the following:
    • * - If the command is running in an interactive job, display output messages on the screen, otherwise display them on a printout named QSYSPRT.
    • *PRINT - Display output messages on a printout named QSYSPRT.
    • *NONE - Do not display output messages.
    Example of output messages from the command UNZIP2 in Figure 3:
      inflated: a.txt                           
      created: zip/css/                         
      inflated: zip/css/css.css                 
      inflated: zip/css/cssprint.css            

Examples:

  1. Let us go back to the first example of command ZIP2. In that example, zip file /tmp/zipFile1.zip contains
    • stream file a.txt without a path, plus
    • directory zip/css containing two stream files, css.css and cssprint.css.
    Suppose that we run command:
    UNZIP2 ZIPFILE('/tmp/zipFile1.zip') TGTDIR('/h')
    In this case, directory h will be added the following objects:
    • stream file /h/a.txt
    • directory /h/zip
    • directory /h/zip/css
    • stream file /h/zip/css/css.css
    • stream file /h/zip/css/cssprint.css
  2. If instead of unzipping the objects to directory /h, we unzip them to the root directory / with command
    UNZIP2 ZIPFILE('/tmp/zipFile1.zip') TGTDIR('/')
    • the root directory is added stream file /a.txt
    • while the already existing stream files
      /zip/css/css.css and
      /zip/css/cssprint.css
      are replaced by the ones inflated from the zip file.