From b2bfc5a2ddf66d18d96fe8936915435db34b4042 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Thu, 10 Dec 2015 16:57:31 +0000 Subject: Force MsgRelayController to use bash --- .../uk/co/blatech/blaears/controllers/MsgRelayController.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/main') diff --git a/src/main/java/uk/co/blatech/blaears/controllers/MsgRelayController.java b/src/main/java/uk/co/blatech/blaears/controllers/MsgRelayController.java index a89b47c..43a5439 100644 --- a/src/main/java/uk/co/blatech/blaears/controllers/MsgRelayController.java +++ b/src/main/java/uk/co/blatech/blaears/controllers/MsgRelayController.java @@ -1,6 +1,7 @@ package uk.co.blatech.blaears.controllers; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -9,12 +10,16 @@ import java.io.IOException; @Controller public class MsgRelayController { @RequestMapping("/msgrelay") - void relay(@RequestParam(value="text", required=true) String text){ + String relay(@RequestParam(value="text", required=true) String text, Model model){ try { - Runtime.getRuntime().exec("echo theblueroom test | ./msgrelay.bash " + text); + Runtime.getRuntime().exec(new String[]{"/bin/bash", "-c", "echo theblueroom test " + text + " | bash /home/smsd/msgrelay.bash "}); + model.addAttribute("result", "OK"); } catch (IOException e) { - System.out.println("Failed to run command echo theblueroom test | ./msgrelay.bash " + text); + System.out.println("Failed to run command echo theblueroom test " + text + " | bash /home/smsd/msgrelay.bash "); e.printStackTrace(); + model.addAttribute("result", "failed"); } + + return "msgrelay"; } } \ No newline at end of file -- cgit v1.2.3