Fixed the issue that caused the process runtime to not account for arguments correctly inside the HeartbeatTask #8
@@ -5,6 +5,7 @@ import net.dv8tion.jda.api.events.GatewayPingEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Scanner;
|
||||
import java.util.TimerTask;
|
||||
|
||||
@@ -22,8 +23,10 @@ public class HeartbeatTask extends TimerTask {
|
||||
long ping = JdrBot.jda.getGatewayPing();
|
||||
|
||||
try {
|
||||
Process p = Runtime.getRuntime().exec(command.replaceAll("\\{ping\\}", String.valueOf(ping)));
|
||||
String[] commandToRun = {"bash", "-c", command.replaceAll("\\{ping\\}", String.valueOf(ping))};
|
||||
Process p = Runtime.getRuntime().exec(commandToRun);
|
||||
if(JdrBot.debugMode) {
|
||||
System.out.println("DEBUG: Ran command \""+ Arrays.toString(commandToRun) + "\"");
|
||||
try (InputStream inputStream = p.getInputStream(); Scanner s = new Scanner(inputStream).useDelimiter("\\A")) {
|
||||
System.out.println(s.hasNext() ? s.next() : "");
|
||||
} catch (IOException e) {
|
||||
|
||||
Reference in New Issue
Block a user