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 a 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.

Upon installation of this utility you may play with stream files a.txt and b.txt in IFS directory /zip/test.

1 - Command ZIP/ZIP

                             Zip stream files (ZIP)                             
                                                                                
 Type choices, press Enter.                                                     

 Target zip file  . . . . . . . . TGTZIP  /tmp/myZipFile.zip                        
                             
 Stream files / directories . . . STMFS   /zip/test/a.txt                           
                              
                      + for more values   /zip/test/b.txt                           
                                                                               
 Don't record directory names . . JUNK    *YES        *YES, *NO
 Update the existing zip file . . UPDZIP  *NO         *YES, *NO
 Replace target zip file  . . . . REPLACE *NO         *YES, *NO
 Output messages  . . . . . . . . DSP     *           *, *PRINT, *NONE, *YES, *NO
Figure 1 - Command ZIP

Use this command to create a zip stream file containing one or more compressed IFS objects.

  • 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 - ending with an asterisk (*) - 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:
      adding: a.txt (deflated 2%)                    
      adding: b.txt (deflated 2%)                    
    Figure 3 - 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:
    64 Sat Sep 23 17:44:00 UTC 2017 a.txt    
    64 Sat Sep 23 17:44:20 UTC 2017 b.txt
Figure 4 - Displaying a zip file


3 - Command ZIP/UNZIP

                           Unzip a stream file (UNZIP)                          
                                                                                
 Type choices, press Enter.                                                     
                                                                                
 Stream file  . . . . . . . . . . STMF     '/tmp/myZipFile.zip'                   
                              
 Target directory . . . . . . . . TGTDIR   '/tmp2'                                
                              
 Password if encrypted file . . . PASSWORD *NONE              
 Output messages  . . . . . . . . DSP     *        *, *PRINT, *NONE, *YES, *NO
Figure 5 - 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:
    Archive:  /tmp/myZipFile.zip                             
      inflating: /tmp2/a.txt                                 
      inflating: /tmp2/b.txt                                 
    Figure 6 - 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) .