Skip to content

Instantly share code, notes, and snippets.

@bsmaat
Created November 10, 2016 18:52
Show Gist options
  • Save bsmaat/e54936b5b89aef890bb032d1302bd4f6 to your computer and use it in GitHub Desktop.
Save bsmaat/e54936b5b89aef890bb032d1302bd4f6 to your computer and use it in GitHub Desktop.
public boolean downloadWithDeluge(String magnetSite) {
String command = "deluge-console add -p /home/billy/deluge-downloads/ " + magnetSite;
//String command = "ping -c 4 google.com";
String out = executeCommand(command);
System.out.println(out);
return false;
}
private String executeCommand(String command) {
StringBuffer output = new StringBuffer();
Process p;
try {
p = Runtime.getRuntime().exec(new String[]{"bash","-c",command});
p.waitFor();
BufferedReader reader =
new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = "";
while ((line = reader.readLine())!= null) {
output.append(line + "\n");
}
} catch (Exception e) {
e.printStackTrace();
}
return output.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment