Skip to Content
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

To report this post you need to login first.

9 Comments

You must be Logged on to comment or reply to a post.

  1. Michael Nicholls
    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

    (0) 
  2. Thorsten Stork
    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

    (0) 
  3. Leela Morampudi
    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.

    (0) 
  4. Smitha Madhavan
    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

    (0) 

Leave a Reply