How to run local script from server?

Viewed 27

so I'm using a spring boot application, and I want to send an api call with a script name, then the server would run the appropriate script as it's in the same repo. But I'm not sure how to do this as the file isn't found?

I am trying to do this while the app is running on localhost, but I'll eventually need to figure it out for aws and running a shell script from within that repo while the server runs there. Below is my basic controller, using process builder to run the script. I'd really appreciate any help, thank you!

@PostMapping
public ResponseEntity<SampleRest> runScript(@Valid @RequestBody ScriptsDetailsRequestModel scriptDetails)
string [] cmd = new String[] {scriptDetails.getScriptName()}
ProcessBuilder pb = new ProcessBuilder(cmd)
try {
    Process p = pb.start()
} catch (IOException e) {
    e.printStackTrace();
}
.
.
.
return new ResponseEntity<SampleRest>(returnValue, HttpStatus.OK)
0 Answers
Related