Skip to Content
Author's profile photo Michal Krawczyk

XI/PI: Command line sample functions

Many people on the XI forum are asking about the command line utility (which is available with some adapters
– like File/FTP adapter for example). In this weblog I’m going to present two very simple scenarios
with which using command line can be quite useful.

Case 1

Imagine you need to send the target file to many folders. Would it be wise to create many receivers
(for every folder) and try to use many file adapter communication channles? What if the file had 20 or 50 Mb?
Would you want to overload your file adapters making them create the same file many times? If the answer is “No”
check out the batch file code below. The first example will copy the output file to 4 locations and delete
the old file from the original location:

File adapter configuration looks like this:

image

Variables used:

%f – original file name

%F – absolute file name (including whole path)

Case 2

We need to archive the target file in a ZIP file. Do we need to write an adapter module for that? Not necessarily
we may try to use a command line archive program. One of them is 7-ZIP ( 7-Zip Command Line Version ).
This example will archive the incoming file to z ZIP file with the same name as the file initially had
and once more remove the “old” file.

Reference:

How to check command lines execution:

XI: Operation system command – error catching

To get more batch file commands:

Batch File Command Reference for Windows 2000

Assigned Tags

      10 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      Hi Michal

      Zipping a file can also be done with jar.

      For example,

      jar cvf m.zip m.txt

      will zip m.txt into m.zip

      No need for any other software as jar is highly likely to be on the XI/PI server...

      Cheers

      Author's profile photo Michal Krawczyk
      Michal Krawczyk
      Blog Post Author
      hi Michael,

      nice to know:)

      thanks for you input! 🙂

      Regards,
      michal

      Author's profile photo Former Member
      Former Member
      tx mick
      Author's profile photo Former Member
      Former Member
      Hi,

      Can you tell me where you put the 7za.exe on the xi server?

      Thanks in advance,
      Laurence

      Author's profile photo Former Member
      Former Member
      Hello,

      can we execute FTP commands with the "command line feature" or system command on the ftp server?

      We want to archive (copy) a file, sent by FTP adapter (receiver adapter).

      regards

      Author's profile photo Former Member
      Former Member
      Dear Michal,

      Firstly sorry, that I am sending mail to ur personal mail ID.

                I am having one doubt. Could u please help me in this issue.

                             In  a file to file scenario, the input file will be picked from a directory location and after processing output file will be placed in the output directory location specified in the receiver communication channel.

      In the sender communication channel for the scenario mentioned above, if the processing mode is given as delete, the input file will be delete as soon as the file was successfully read by the adapter, but this will not ensure that the file processing is complete and the output file is being created.

      If we have a scenario in such as way that the input file should be deleted from the input folder only if the complete process is successful and the output is generated. how can we achieve this functionality?. send me your reply as soon as possible.

      Author's profile photo Former Member
      Former Member
      Hi Michal,
      Very helpful post.. Thanks you so much!

      You have mentioned about the receiver adapter, can i do the same using the sender adapter- i.e sender adapter reads a file and then using OS commands it should write it back too. Let me elaborate....
      I need to use the sender adapter to pick a file from a filesystem;unzip it using the unzip module and then write the unzipped xml to another folder in the filesystem using "Run OS level command after message processing". Please let me know if this is possible? And do I have to have a bat file to perform the copy or include it in the command line directly?

      Regards,
      Smitha

      Author's profile photo Madan Agrawal
      Madan Agrawal
      Its a nice blog!
      The discussion below the blog is also very helpful.
      Keep it up..

      Br,
      Madan Agrawal.

      Author's profile photo Former Member
      Former Member

      Hi Michal Krawczyk , we need to execute windows command in a windows server from our sap pi. But our sap pi server is in an unix server, could you tell us if is possible execute this windows command? thanks a lot.

      Author's profile photo Bharath Vishwanath
      Bharath Vishwanath

      Hi Michael ,

       

      I need your help where I'm using the 7.5 single stack Po  where the scenario is proxy to sftp , basis team have created shell script and I'm using the shell scrip in the receiver sftp channel in message log i can see that command is executing but nothing is happening . could you please help where is the issue , it will be really helpful to me.

       

      Thanks & Regards

      Bharath.vishwananth