cancel
Showing results for 
Search instead for 
Did you mean: 

ZIP files using OS Command only

markbernabe
Active Participant
0 Kudos

Hi Experts,

Is it possible to zip files on a particular SFTP directory using native OS commands (without Shell script)? I mean, just indicate certain commands directly in the OS Command line (Run after message processing line) to zip the file. Our Basis is not keen in using shell script and doesn't want to upload any script in the PI server.

Appreciate your inputs.

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

As some of the people wrote, you cannot run any OS command on a SFTP-server using the standard SFTP-adapter.

However, the ADAEPTIVE SFTP-adapter can run remote SSH-command. Of course, your SFTP-user needs the rights to run commands over SFTP/SSH.

Using the standard SFTP, you can only use the payloadzipbean.

If this one does not suit you, you might develope your own java bean. I guess, zipping in java is not complicated.

Former Member
0 Kudos

Hi Mark,

We can execute native OS commands only for NFS protocol. As you mentioned you need it on SFTP its not possible from channel.

Regards,

Pranav

iaki_vila
Active Contributor
0 Kudos

Hi Mark,

According with http://www.linuxcommand.org/man_pages/sftp1.html and http://linux.about.com/od/commands/a/blcmdl1_zipx.htm you can try with using ! before the zip or unzip command.

In my opinion i dont like so much to use the OS command line if there is another solution available, i think is easier to take create an scenario for this take the file, zip with payloadzipbean in PI and deposite the file in the same directory.

Regards.

Message was edited by: Iñaki Vila

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You can try using the below syntax

unzip name.zip -d /some directory path

As a starting pt, google for the commands using unix or linux like sample below...

http://www.cyberciti.biz/faq/linux-howto-unzip-files-in-root-directory/

Some unix versions you need to do untar command instead of unzip in linux.

markbernabe
Active Participant
0 Kudos

Hi Baskar,

Thanks for the response. I would have to zip the file instead of unzip. I tried:

zip -m name.zip *.csv /same as the target directory in the receiver channel

The audit logs says the OS command is executed but the file didn't get zipped and remained csv.

Did I miss any step?

praveen_sutra
Active Contributor
0 Kudos

hi Mark,

If its windows based system. COMACT is the command you need to use.

Secondly if you have winzip or some other third party compressing tool available mention the path of the exe file..

c:\Programfiles\zip -m name.zip *.csv /same

or you can use

http://scn.sap.com/thread/1845624

cmd /C "jar cvfM
10.11.128.28\sapmnt\put\TEST\test.zip -C
10.11.128.28\sapmnt\put\TEST\zip ."

This will create a zip folder named test.zip in directory
10.11.128.28\sapmnt\put\TEST\ . The contents of the zipped file will be taken from
10.11.128.28\sapmnt\put\TEST\zip

alternatively.

hope this helps,

thanks and regards,

Praveen T

markbernabe
Active Participant
0 Kudos

Hi Praveen,

Thanks for the info. However, we're using Unix instead of windows. Do you have an idea?

praveen_sutra
Active Contributor
0 Kudos

hi Mark,

Have you tried this:

zip -m -R name.zip *.csv /same

http://www.computerhope.com/unix/zip.htm

hope this helps.

thanks and regards,

Praveen T

markbernabe
Active Participant
0 Kudos

Hi Praveen,

I tried the same command but the file is still not zipped. If I intend to zip the file in the sender channel, do I use Before or After message processing?

praveen_sutra
Active Contributor
0 Kudos

Hi Mark,

As per my understanding you should use after message processing.

thanks and regards,

Praveen T