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 1

This set is based on some zip and unzip commands which can be downloaded, installed and run in the IBMi Qshell (a command environment based on POSIX and X/Open standards).
Instructions about doing this can be found in the IBMi Redbook IBM HTTP Server (powered by Apache), APPENDIX C: Bringing Zip and Unzip to i5/OS PASE and Qshell Environments by Brian Smith.

Our tool performs the install of these basic commands during its installation process, so that you dot not have to do it manually by yourself.
Appendix A shows how to use these commands in the Qshell environment.

However, if you are an ILE-RPG developer, you would like to have something more manageable. This is why we have developed two handy CL commands - ZIP and UNZIP -based on the Qshell ones.

After installing this utility you may work with stream files a.txt and b.txt in IFS directory /zip/test.

1 - Command ZIP/ZIP

Figure 1 - Command ZIP

The ZIP/ZIP command copies and compresses stream files and directories into a single archive (target) file.
The contents of the archive file can be displayed by running command ZIP/DSPZIP2.
The information in the archive file can be decompressed and copied back by running command ZIP/UNZIP or (if available) command CPYFRMARCF.
The archive file can also be decompressed on other operating system platforms by running any of the tools that can decompress an archive.
Command execution- There are two possible ways:

  1. If the operating system release is at least V7R2, parameter STMFS specifies a single stream file or directory, parameter UPDZIP is *NO, and parameter JUNK is *NO, then command CPYTOARCF is executed.
  2. In all other cases, a synchronized batch job is submitted and compression is performed by QSHELL ZIP command.
Restrictions:
  • You must have at least read (*R) authority to the files or directories to be archived. You must also have at least *R authority to each directory in the path in the path names preceding those files or directories.
  • If the QSHELL ZIP command is executed, the total size of the objects to be compressed cannot exceed 2 gigabyte.

  • Target zip file (TGTZIP) - The target .zip stream file.
  • Stream files / directories (STMFS) - You can specify up to 50 names of IFS objects to be compressed. Each entry can be
    • a stream file name (example: /tmp/a.txt ), or
    • a directory name (example: /tmp ). When a directory name is specified, all the objects in that directory are taken.
    Note 1: Generic names - containing asterisks (*) - are not supported.
  • Don't record directory names (JUNK) - Usually the Qshell ZIP command command (which is executed from command ZIP/ZIP) includes - in the zipped file - the paths (directory names) of the zipped stream files. However, if you specify JUNK(*YES), the Qshell ZIP command is executed with descriptor -j and this causes the paths (directory names) of the zipped files to be ignored.
  • Update the existing zip file (UPDZIP) - Select one of the following:
    • *NO - The content of the zip file will be completely new. If the file already exists, REPLACE(*YES) must be specified.
    • *YES - If the zip file already exists, the existing zipped files are updated and new zipped files are added. The REPLACE parameter is ignored.
      If - instead - the zipped file does not exist, an escape message is issued and the command is terminated.
  • Replace target zip file (REPLACE) - Wether the target zip file should be replaced if already existing.
    Note. When UPDZIP(*YES), parameter REPLACE is ignored.
  • Output messages (DSP) - Whether and how the output messages from the Qshell "zip" command should be displayed.
    Select one of the following:
    • * or *YES - 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 or *NO - Do not display output messages.
    Example of messages output:
    Figure 2 - Output from command ZIP
Note 2: Qshell command "zip" does not support encryption.
Note 3: The maximum size of the data to be zipped is 2 Gigabyte. If exceeded, the Qshell "zip" command outputs a failure message.


2 - Display the contents of a zip file

The Qshell "zip" command does not provide any feature to display the contents of a zip file.
The contents of a zip file can however be displayed by command ZIP/DSPZIP2 (see the next page) which is based on the Qshell "Jar" command.

Example: the display of zip stream file "/tmp/myZipFile.zip" created as per Figure 1, will show as follow:
Figure 3 - Displaying a zip file


3 - Command ZIP/UNZIP

Figure 4 - Command UNZIP

Use this command to unzip a stream file.

Note 3: Command ZIP/UNZIP executes the Qshell command UNZIP with descriptor -j . In this way, the path (directory names) of a zipped stream file (if recorded with the file name) is discarded, and the unzipped file is built in the path specified by parameter TGTDIR.
  • Stream file (STMF) - The stream file to be unzipped.
  • Target directory (TGTDIR) - The IFS directory where the compressed (zipped) files should be inflated.
  • Password if encrypted file (PASSWORD) - If the zip file is encrypted, use this parameter to specify the protection password.
    If the zip file is not encrypted, leave the default PASSWORD(*NONE).
    WARNING - The password is case sensitive. If the password contains lowercase characters, it must be enclosed in quotes (').
  • Output messages (DSP) - Whether and how the output messages from the Qshell "zip" command should be displayed.
    Select one of the following:
    • * or *YES - 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 or *NO - Do not display output messages.
Example of message output:
Figure 5 - Output from command UNZIP

Note 4: Any unzipped (inflated) file is always assigned CCSID 819 (ASCII) from Qshell, though the file data stays unchanged. If the original file data had a CCSID other than 819, the data of the unzipped file are now meaningless until the appropriate CCSID is restored. The UNZIP program has no way to retrieve the original CCSID of the data, therefore it is a user responsibility to restore it on the unzipped file, unless the original file was an ASCII one. This can be done by using command CHGATR.
Example: assume that the unzipped file data /tmp2/a.txt need to be re-assigned their original CCSID 37. Run this command:
CHGATR OBJ('/tmp2/a.txt') ATR(*CCSID) VALUE(37) .