Skip to Content

ZIP certain files in a directory using external OS commands

Hi all,

I want to zip certain files in a certain directory using an external OS command in SM69.

For example:

in directory /abc/xyz I have the following files:




Now only the files starting with 'filea' have to be put into an archive file (zip file) with name

How to do this?

I already searched the forum and tried by using the unix command syntax, but I didn't succeed yet. So I guess I could use some help here. Please be precise in how to fill in all the parameters in SM69 since I have already tried a lot of combinations.

So please be so kind and answer my question by giving the exact commands and parameters per entry below:

1. Operating system command

2. Parameters for operating system command

3. Additional parameters (if necessary)

Thanks in advance.


Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Jan 14, 2012 at 03:01 PM

    The procedure below works on any UNIX based application server as it uses only standard gzip and tar commands that are available on any UNIX system. If you want to use third party zip utilities installed on your UNIX system, to do zipping like Winzip does, then you need to tailor the script below accordingly.

    You need to create a two liner shell script for this as this involves a series of UNIX command joined by pipe which require arguments.

    I tested this on my machine and found it working

    1. Create a shell script say with the following coding

    #! /usr/bin/sh
    find $1/* -prune -type f -name "$2" | xargs tar cf - | gzip -9c > $3

    In the above $1 is file path and $2 is file name where you can pass filename mask like filea*.

    find searches the files in the specified path (no recursive subdirectory search) and pipes the names to tar. If you want to search subdirectories also remove the -prune option.

    tar simply concatenates the files together into a .tar file, which gzip will later zip into .gz file

    gzip -9c: (9) is highest compression, (c) means to write to the standard output which we redirect to filename passed in argument $3

    2. Put the script on a server path that is accessible to the SAP system user. Ensure that execute permission is set on this file. If required use chmod command like below

    chmod 755 <path>/

    3. Go to SM69 and create a command name like below

    Command name = ZTAR
    Operating system command = <path>/
    Parameters for operating system command = ? ? ? 

    You need to save the command, press f3 and save again. Otherwise the command doesn't really save

    4. You can now execute the command in SE37 using function SXPG_COMMAND_EXECUTE. Ensure you have write permissions on the output paths and read/open permissions on all files that are to be zipped.

    Upper/lower case = 'X'
    ADDITIONAL_PARAMETERS = <path of files to be zipped> filea* <output path>/output.tar.gz

    or alternatively you can also test using SM49 transaction.

    This means that the 3 additional parameters above substitute the three ? place holders mentioned in step 3

    The above steps will tar all the files matching filea* and then gzip them.

    Best regards,

    Vishnu Tallapragada

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.