cancel
Showing results for 
Search instead for 
Did you mean: 

Shell Script in Mapping

Former Member
0 Kudos

Hi All,

I have uploaded the .Jar and all the related files on the server in the folder com/XXXX/Signature.

When I execute using the command(say Java com/XXXX/Signature) I am able to run the program and get the output.

Now I want to use these shell script in a UDF in mapping.

Can somebody help me out on how to use these shell scripts in XI UDFs.

Helpful answers will be rewarded points.

Thanks & Regards,

RK

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Rupash

There can be multiple ways to do this. You can create a package of your own and import it to XI and use as a import while creating the UDF. Pass the parameters from UDF to the parent class to execute this.

Another way can be execute the Script from UDF giving complete path of a XI server location.

If you are getting any error let us know.

Check this also for creating XML signature in XI

Thanks

Gaurav

Former Member
0 Kudos

Hi Gaurav,

I have imported the files in XI server.

I am passing a string from mapping as input to calculate the signature.

I just want to know how to invoke the methods as I am getting error.

Any sample UDF for this would be great.

Thanks,

RK

Answers (2)

Answers (2)

Former Member
0 Kudos

ok

Former Member
0 Kudos

HI Rupash

Check some UDF examples here may be it will help

https://www.sdn.sap.com/irj/scn/wiki?path=/display/xi/service%252bfor%252bthe%252buser%252bdefined%2...

Give more details is what are the files and how you want to invoke then we can try to help more on this

Thanks

Gaurav

Former Member
0 Kudos

Hi Gaurav,

I have the class and everything ready and I have tested it using JCreator and the signature is generated and verified.

Now I am passing a string while testing from JCreator.

I will be passing the same string from XI mapping.

It has to access the class using shell scripts.

I think we need to use the command java com/XYZ/BACK/GenerateSignature from XI server to test it.

Could you please provide me the code to access the shell script commands from UDF?

Thanks & Regards,

RK

Former Member
0 Kudos

Hi Rupash

package com;

import java.io.*;
import java.util.*;


public class ScriptBuilder {
public ScriptBuilder() {
}

public void writeScript() throws java.io.IOException {
Runtime rt = Runtime.getRuntime();
rt.exec("chmod 777 testinglinux.sh");
Process p = rt.exec("./testinglinux.sh");
try {
p.waitFor();
} catch (Exception e) {
e.printStackTrace();
}
String shellfilename = "testing.txt";
if (new File(shellfilename).exists()) {
System.out.println(shellfilename+" File exists");
}
}

public static void main(String[] args) throws java.io.IOException {
ScriptBuilder sb = new ScriptBuilder();
sb.writeScript();
}
}

This is the class where i am executing the shell script. import the package and use as imports and then execute it calling directly package class method. it should call the script.

I didnt have the system right now to test and let you know. Give it a try

Thanks

Gaurav