How to connect to an external server and execute shell script from Pega

Hi All,

I need urgent help on this requirement.

Could anyone please tell me a way to establish connection with external server(Axiom server) and execute a shell script in that server.

As per my understanding the connect-ftp method using the ftp server instance can be used to connect to an external system and perform the file transfer. But in my requirement, Pega needs to connect to the axiom server and need to execute the script there.

Also I found the below java code to execute the shell script which seems to got deprecated in the latest Pega version(8.8.5). So request you share the steps/options to achieve the above mentioned requirement.

String[] command = {“/bin/bash”, “test.sh”, “Argument1”};
ProcessBuilder p = new ProcessBuilder(command);
Process p2 = p.start();
BufferedReader br = new BufferedReader(new InputStreamReader(p2.getInputStream()));
String line;

System.out.println("Output of running " + command + " is: ");
while ((line = br.readLine()) != null) {
System.out.println(line);

Error received while trying to run code:

Java code injection pattern identified in the java source code. Vulnerable code detected: newProcessBuilder(

Thanks in advance,

Sindhu S

@Sindhu S I am trying to get a Security team member to help you with this question but I believe the functionality is not documented as it may pose application security risks.

Are you referencing this post How can I execute a shell script from Pega? from 6 years ago?

I found closed question for Pega 8.3 : Execute shell script from PEGA which gives you insight into the more recent versions.

The solution points users to a Security chapter in our legacy documentation which states that “… by default, Pega Platform reports errors at design time and run time, and does not run any activity, function, or stream rule that was created in Pega Platform. This includes includes any of the following: Runtime.getRuntime() new ProcessBuilder() JavaCompiler org.dita.dost.invoker. If the rule is created in a version prior to 8.3, the behavior of the upgraded/imported rule in the 8.3+ system depends upon the value of the dynamic system setting security/enableJavaInjectionMitigation as defined in the article above”.

The updated functionality is documented here:

Issues resolved with update impact

Configuring the Java injection check

cc @garht @sasuk

You can explore Axiom REST APIs and see if you can use that with connect rest to meet your needs.

https://axiom.co/docs/restapi/introduction