cancel
Showing results for 
Search instead for 
Did you mean: 

OS Command feature in FTP receiver

Former Member
0 Kudos

HI Experts,

This is regarding the Command line feature available in FTP channels.

Scenario : File to File

1. Is it possible to create a copy of the output file onto another directory in the target FTP server using this feature? Or is this not possible as the SAP note 841704 mentions "for the File Adapter transport protocol "FTP", the operating system command is NOT executed on the FTP server, but on the server hosting the Adapter Engine." If i want a copy onto another directory in the remote server, what are the steps to be followed?

( have gone through Michals blog /people/michal.krawczyk2/blog/2007/02/08/xipi-command-line-sample-functions but was not able to try it as i dont have permisstion to tcode SXDA_TOOLS - i believe the batch file should be uploaded to al11 using this - correct me if i am wrong here!)

2. Can we give command directly onto the command line text box (without mentioning batch file path) ? I tried using the Transport protocol as NFS and routed the file to a local directory /usr/sap/tmp with the command line having a simple command as mv %f filechange.txt. This is shown as executed successfully in CC monitoring but result is not seen.

Would like to know the possibilities of this feature- thanks in advance!

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Thanks for all the answers..problem is solved while using NFS. Will post another thread if facing problems with remote execution of script.

Diya

Former Member
0 Kudos

Thanks for the clue regarding the prefix. The channel is not showing any error now. It shows that the command is executed succesfully but i cannot see the result of the execution.

Channel status:

2011-07-25 12:15:10 Success Write to file "/usr/sap/tmp/Output.txt" as text (character encoding ISO8859-1) size 124 bytes

2011-07-25 12:15:10 Success Execute OS command "sh /usr/sap/tmp/testftp.sh /usr/sap/tmp/Output.txt"

2011-07-25 12:15:16 Success File processing complete

2011-07-25 12:15:16 Success MP: Leaving module processor

2011-07-25 12:15:16 Success The message was successfully delivered to the application using connection File_http://sap.com/xi/XI/System.

2011-07-25 12:15:16 Success The message status set to DLVD.

The output file is created in /usr/sap/tmp. But the sh file contains a command : cp %1 /usr/sap/tmp/new.txt. This file is not created however. Any ideas?

former_member854360
Active Contributor
0 Kudos

Hi Diya,

also in text box use uppercase F like: %F

Please use $1 instead of %1

cp $1 /usr/sap/tmp/newfile.txt

cp file1 file2  copy file1 to a file called file2 
 
cp file1 /tmp  copy file1 to the /tmp directory 
 
cp file1 ~smith  copy file1 to the home directory of "smith" 
 
cp * /tmp  copy everything in the directory to the /tmp directory

refer this

http://help.sap.com/saphelp_nw04/helpdata/en/e3/94007075cae04f930cc4c034e411e1/content.htm

When the operating system command is called, the file name currently being processed can be specified with the following placeholders:

u25CF        %f (file name)

u25CF        %F(absolute file name including path)

Former Member
0 Kudos

Hi,

You must use full path (%F with uppercase), so your script doesn't have the path of source file:

sh /usr/sap/tmp/testshell.sh %F

Regards,

CArme

Former Member
0 Kudos

I agree with Debashish,

In text box, pass F% (if you need to pass full path) parameter to the Script

In Shell Script Use:

chmod 777 $1

cp $1 /directory/new.txt

Check File access permissions

Former Member
0 Kudos

Hi SDNers,

I was able to execute command line functions by directly giving it in the text box (with transport protocol as NFS). However, the same is not working when i am trying through a batch file. Below is what i did.

1. Uploaded batch file "testftp.bat" to /usr/sap/tmp folder in XI.

2. Gave this path in command line as /usr/sap/tmp/testftp.bat %f

3. testftp.bat contains only one line - rm %1.

rm %F when directly given in the command line text box functioned succesfully. I tried giving the path in various ways but dint work. Please can anyone guide as to how to give the path / if something is wrong in the batch file?

former_member854360
Active Contributor
0 Kudos

Hi Diya,

Add cmd.exe before the actual command in textbox

Gave this path in command line as /usr/sap/tmp/testftp.bat %f

Foe example write it in textbox

cmd.exe /usr/sap/tmp/testftp.bat %f

Former Member
0 Kudos

I agree with Debashish.

In Windows OS, you need to add cmd.exe at the start of the command box:

cmd.exe /usr/sap/tmp/testftp.bat %f

In Unix OS, you need to add sh at the start of the command box:

sh /usr/sap/tmp/testshell.sh %f

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You can create script and specify it as os command in the channel for your need. Have you seen this [link|http://wiki.sdn.sap.com/wiki/display/XI/SAPXIFileAdapterOSCommandLine+Feature]?

former_member854360
Active Contributor
0 Kudos

Hi Diya,

In case of nfs you can directly write the command in the text box.

But in case of FTP you need to create one Batch(.bat file incase windows) or shell script file (Linux) .

From PI comm channel you can run this file in FTP server.

Refer this document for FTP commanmd.

http://www.way2sap.com/sap-article/SAP-XI-File-Adapter-OS-Command-Line-Feature-805/

Edited by: Debashish on Jul 1, 2011 11:49 AM

Former Member
0 Kudos

Hi Debashish,

I tried giving command directly while using NFS but it dint work. (Point 2 in the original post). Do you know the reason for that?

former_member854360
Active Contributor
0 Kudos

Hi ,

Can you please share the command what you are using in text box?

rajasekhar_reddy14
Active Contributor
0 Kudos

Hi Thomas,

OS Comman feature supports both FTP and NFS.

Write one Schel script to copy data in to multiple folder, this is one option.

second option: if you want to copy same data in to different folder then create one more receiver agrement with different channel,it will work.

Regards,

Raj

Former Member
0 Kudos

I completely agree with Raja's post!