cancel
Showing results for 
Search instead for 
Did you mean: 

Need help on run OS command

former_member200386
Active Participant
0 Kudos

Dear Experts,

I am working on one requirement where i need to add .pgp extension to my source file name.

like this below example,

my source file :sf_out_123.txt

desired filename:sf_out_123.txt.pgp

my scenario is File(NFS)- SFTP(pass trhru) no ESR involved.

I have gone through this below blog

http://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=272171407

we can acheive this using run OS command.

we are using windows server 2008. 

please provide me the suggestions to achieve my requirement.at sender comm channel(run OS command before processing)  end.

1) do we need any additional configuartion required to run OS command?(adding environment varibales, path .....etc)

2) what will be the sytnax to rename the file.

Thanks & Regards,

Pavan

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

hi Pavan,

you can create a file-to file scenario with no mapping and use OS command on receiver file channel.

For changing name - a small OS command "rename %f %f.pgp" on windows

"mv %f %f.pgp" on Unix should work. I don't think any additional configuration is required.

Regards,

Ankit

former_member200386
Active Participant
0 Kudos

Hi Ankit,

Thanks for the prompt response. SFTP adapter don't support OS command execution.

I have to use at sender File channel(before Message processing)

Thanks & Regards,
pavan

anupam_ghosh2
Active Contributor
0 Kudos

Hi Pavan,

     Could you please elaborate what kind of adapter you are using in receiver side?

Does the adapter offer OS command facility?            

Regards

Anupam

former_member200386
Active Participant
0 Kudos

Hi Anupam,

I want to use OS command at Sender File comm channel( before message processing).

my end to end scenario is

File(NFS) to SFTP  (pass thru) no ESR involved

end my exact requirement for using OS command is

i need to add .pgp extension to my source file and send to target SFTP .

like this my source file name:sf_out_*.txt

desired filename:sf_out_*.txt.pgp

Thanks & Regards,

Pavan

anupam_ghosh2
Active Contributor
0 Kudos

Hi Pavan,

             You can try putting this command

cmd.exe /C "ren %F %F.pgp"

However I think you cannot use this feature to rename a file in sender file adapter.

The reason being adapter after picking up the file will execute the command which will change the file at OS level.  This will not change the filename of the file already picked up. In case this does not work then  you need to check the receiver file adapter with following questions

1. Does it suport Dynamic configuration (ASMA) ?

2. Does it support OS command feature?

If you are using SAP SFTP adapter it lacks OS command line feature. Thus only options are to use custom adapter module or add an java mapping code in the scenario. Please check this wonderful blog by Shabarish Vijayakumar.  The other helpful articles are

http://wiki.sdn.sap.com/wiki/display/Snippets/Dynamic+file+name+in+a+File+to+File+pass+through+scena...

http://wiki.sdn.sap.com/wiki/display/XI/Dynamic+file+name+for+pass-through+scenario

  

Regards

Anupam

former_member200386
Active Participant
0 Kudos

Hi Anupam,

Thanks for the Response. i have changed my design plan.

File (Content conversion) NFS to  File (content Conversion) NFS

I am using ESR objects now.

Please find the screen shot of my design

my scenario is working fine end to end. But need to add .PGP extension to file name is still pending.

I need to UDF to add .pgp extension to my source file.Please provide me your valuable inputs.

Thanks & Regards,

pavan

anupam_ghosh2
Active Contributor
0 Kudos

Hi Pavan,

                In case of file to file scenario just add an UDF to your scenario

public String AlterFileName(String Message,Container container){

String filename    = "";

String timestamp = "";

DynamicConfiguration conf1 = (DynamicConfiguration) container .getTransformationParameters() .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");

filename = conf1.get(key1); 

filename = filename+".pgp";

conf1.put(key1,filename);

return Message;
}

The UDF needs to be written as shown below

Message------>AlterFilename------>Message.

Please check this blog for further settings required in both sender and receiver comm channels to access ASMA http://saptechnical.com/Tips/XI/ASMA/Index.htm

Regards

Anupam

former_member200386
Active Participant
0 Kudos

Hi Anupam,

Thnaks for the response, I got my issue resolved. I used below UDF to Achieve my requirement.

try {

String filename    = "";

DynamicConfiguration conf1 = (DynamicConfiguration) container

    .getTransformationParameters()

    .get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");

filename = conf1.get(key1);

filename = filename.replaceAll( ".txt","");

filename = filename+".txt.pgp";

conf1.put(key1,filename);

return filename;

}

catch(Exception e)

{

     String exception = e.toString();

      return exception;

}