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

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: IFS objects can be single stream files and/or directories.
    If a directory specified, the full contents of that directory (subdirectories and stream files) are zipped.
    Note 5: 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 6: 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 7: 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 8: 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.
  • Replace target zip file (REPLACE) - Wheter the target zip file should be replaced if already existing.
  • 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 9: 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:
  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:
  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

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:


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 unzipped.
  • 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:
    CHGATR OBJ('/tmp2/a.txt') ATR(*CCSID) VALUE(37)
    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) - This parameter is no longer used. It has been maintained for compatibility with previous releases of this command.

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.