cancel
Showing results for 
Search instead for 
Did you mean: 

How to archive files in another ftp server?

xinjiang_li
Active Participant
0 Kudos

Hi,gurus:

My scenario is file to file and my sender adapter is ftp adapter.

Now I want to archive the send file in another ftp server,how can I implement it?

There is a parameter "Archive files on FTP server" when I choose the processing mode "archive".What's it's use?Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

santhosh_kumarv
Active Contributor
0 Kudos

Hi,

With a FTP channel pointing to a FTP server you would be able to access the path of that server alone.

If your requirement is to copy the file to another file server

1. You can write an OS command in the sender file CC that establishes the connection to the another Server and copy the same file to it.

2. Have file receiver scenario that copies the same file to another FTP server using the receiver file ftp cc.

Check my Blog

Thanks

SaNv...

xinjiang_li
Active Participant
0 Kudos

Hi,Santhosh:

Thanks for your reply.

I have checked your blog before,and it is very useful for me.

I still have a problem about command line.

In an sap note,I found the principle of the execution of the command line is like below code:

-


import java.util.*;

import java.io.*;

public class test {

public static void main(String args[]) {

try {

Runtime rt = Runtime.getRuntime();

Process proc = rt.exec("C:/data/test.bat <param1> <param2>");

} catch (Exception e) {

e.printStackTrace();

}

}

}

-


But you know this method has restriction.If my bat file has many commands,it only execute a part of commands(sometimes 8,sometimes 9 ).

My bat file is like below:

-


echo open 192.168.67.149 >c:
data
copyResult.txt

echo <username> >>c:
data
copyResult.txt

echo <password> >>c:
data
copyResult.txt

echo cd /receive>>c:
data
copyResult.txt

echo get %2>>c:
data
copyResult.txt

echo cd /ok>>c:
data
copyResult.txt

echo put %2>>c:
data
copyResult.txt

echo cd /archive>>c:
data
copyResult.txt

echo delete send.txt>>c:
data
copyResult.txt

echo quit >>c:
data
copyResult.txt

ftp -s:c:
data
copyResult.txt

del %2

-


I wanna merge all the "echo" in one command,so it may execute successfully,but I don't know the method.Any ideas?

xinjiang_li
Active Participant
0 Kudos

I still have the problem,could anyone help me ?Thanks in advance.

Former Member
0 Kudos

Hi Li,

You might consider the option of addind another XI File to File scenario to archive the file in another ftp server.

Regards,

Suddha

santhosh_kumarv
Active Contributor
0 Kudos

Hi,

I can give some inputs on the echo command and the combining it together.

The echo is used to display the content but using > & >> the content is appended to the file specified i.e to datacopyResult.txt in C drive in your case.

So u can insert all the command with the echo command in a file and save it as datacopyResult.txt. By this was u can avoid using the echo command for creating the file every time.

datacopyResult.txt

open 192.168.67.149
<username>
<password>
cd /receive
get %2
cd /ok
put %2
cd /archive
delete send.txt
quit

Save the FTP command as a seperate batch file and try to execute the batch file in the command prompt and use it in the XI OS command.

Thanks

SaNv...

xinjiang_li
Active Participant
0 Kudos

Hi,Sãnthosh :

Do you mean that I can save the file datacopyResult.txt as datacopyResult.bat and execute in XI OS command?But it did not work.Any ideas?

Former Member
0 Kudos

1. You can also use the Custom Adapter Modules at Sedner or Receiver side depends on your actual requirements.

In Custom Module you can write a code that will connect with the desired FTP server and put the file at that location.

2. You can also do it in Mapping. Create 2 Mapping...one Java and other Graphical Mapping (depends on transformation logic.). In Java Mapping you can read the source message and write a code to connect with the Remote FTP server and put that message there.

3. Using Command line arguments...but I am not much sure about the writing scripts

Thanks

Farooq

Answers (2)

Answers (2)

xinjiang_li
Active Participant
0 Kudos

Hi,thanks!

The second question was solved.And who knows the solution of the first question?How to archive files in adnother ftp server which is different from the one that send file stay?

Former Member
0 Kudos

Hi Li,

The best two possible approaches I can think about are as follows:

1. Define another File - File scenario in XI. This can be just a passthrough scenario - without mapping - using the same message interface for the source file as both sender and receiver interface. In that way you archive the same file into another ftp server using a Receiver FTP Channel. Otherwise I don't see a way how a sender file adapter itself can send the source file to some other ftp server for archiving.

2. The second approach would be to use a custom ftp script - that can transfer the source file to the other ftp server either under anonymous login or user authentication. Now how XI sender file adapter can contribute in this process? There under processing tab you can use a pre/post processing OS commands to run that script that can move to the other ftp server.

setting the Archive Files on FTP Server indicator; archives the file on the source ftp server only.

Hope this helps.

Regards,

Suddha

santhosh_kumarv
Active Contributor
0 Kudos

>>There is a parameter "Archive files on FTP server" when I choose the processing mode "archive".What's it's use?

Enabling this option will Archive the file in the FTP server, else the file will be archived in the Adapter Engine file system.

Thanks

SaNv...