cancel
Showing results for 
Search instead for 
Did you mean: 

file Adapter "run operating system command"

former_member183909
Active Participant
0 Kudos


Hi

I have seen and viewed piles of discussion and blogs and SAP help about this option in the File Adapter.

Seems easy.  But I cannot get it to work.

My Receiver File Adapter writes my file to a directory OK.  I then run OS command (Windows Server) to unzip the file.

If I do this myself at the command line it works fine. But the same type of command in the Adapter does nothing...I can't even get the results of what it did when piping to an output file.

So I have really dumbed it down and even that does not work from the adapter.

Here is the command

cmd.exe /c "echo hello > errorlog1.txt"

The log for the File Adapter shows this

Information Write to file "D:\TESTHARNESS\TARGET\FILES_EMAILED\LAS_Data_Mar14_03.zip" as binary, size 961380 bytes

Information Execute OS command "cmd.exe /c "echo hello > errorlog1.txt""

Information File processing finished

So why for a Windows server running SAP PI7.31 does this simple command not write out the result of the echo ?

Accepted Solutions (0)

Answers (4)

Answers (4)

former_member202642
Participant
0 Kudos

Hi Jonny,

You can write a shell scripting file to unzip the file. And placed it into some location on the SFTP server.

At Receiver adapter OS command line you just need to provide the path of the script first, name of the file to be unzipped and then the path where you want to place the file.

The OS command line should look like this:

sh -x /<Location where the script is places in server>/<FileName_to_unzip_the_file.sh> <File which is to be unzipped> /<Target location >/

Script should be like this:

******************************************************************************

_FileName=$1

_FilePath=$2

cd $_FilePath

unzip $_FileName $_FileName.zip

chmod 777 $_FileName  (Use this if you dont have the proper permission)

rm $_FileName.zip                   (If you want to delete the zipped file use this command)

***************************************************************************************

P.S.: "<FileName_to_unzip_the_file.sh>" here .sh is the extension that is to be given to the script file which would unzip your file, as this is a shell scripting.

Hope this would help you.

former_member183909
Active Participant
0 Kudos

Thanks  - but forgetting what I really want it to do...   I cannot even get it to write out a simple ECHO - see my first message,

Could it be that the SAPService<SID> userid needs special permissions to allow it to run OS commands ?

former_member202642
Participant
0 Kudos

Jonny,

We came across such a scenario. Which was opposite to yours.

We had to write a password protected zipped file to the target directory.

Although we were able to zipped it successfully, but couldn't able to unzipped it to check if it successfully zipped or not. As we don't have the proper permission.

That's why we used "chmod" to get access.

This might be the case with you also. Check if you have proper permission to do so.

Former Member
0 Kudos

Jonny,

Plz chk the below link

SAP XI File Adapter OS Command Line Feature:

http://wiki.scn.sap.com/wiki/display/XI/SAP+XI+File+Adapter+OS+Command+Line+Feature

..............

Mutti.

Former Member
0 Kudos

Hi Jonny,

Have you tried to create batch file and execute at receiver File communication channel in Command Line?

Regards,

Krupa

former_member183909
Active Participant
0 Kudos

Yes even .BAT does not work.

Could it be that the SAPService<SID> userid needs special permissions to allow it to run OS commands ?

engswee
Active Contributor
0 Kudos

Hi Jonny

Just curious, if you just want to unzip the file, have you tried it using the PayloadZipBean module?

http://help.sap.com/saphelp_nwpi711/helpdata/en/45/da9358a1772e97e10000000a155369/content.htm?frames...

Rgds

Eng Swee

former_member183909
Active Participant
0 Kudos

Yep I tried that too and that did not work on the Receiver Adapter (even though it reported that it unzipped the payload).  Sorry but I'll open up another question on that particular topic later.  I'm just running out of time to get this simple thing working.  thanks anyway.

former_member184720
Active Contributor
0 Kudos

Hi Jonny - Try giving the complete file path?

former_member183909
Active Participant
0 Kudos

Yes - I've followed that and tried all combinations.  Even given the Guest userid the role SAP_XI_CONFIG_FILE_OS_CMD_J2EE  as per 1717530.

In the File Receiver advanced mode tab I have also set oscomamnd.trace = true.

There is an error reported in the log but it seems to provide nothing useful as to the cause even down into the application logs.

former_member184720
Active Contributor
0 Kudos

I don't think you should assign this role to the user "guest" instead to the user who is defining them in Integration Directory  i.e. to your user ID.

1669957 - Authorization to change OS commands in File adapter