Pessoal, estou precisando executar um script python a partir do meu aplicativo java, eu executo qualquer aplicativo com:
try {
Process p = Runtime.getRuntime().exec("/bin/bash -c /usr/bin/pkpgcounter < /root/t2.pdf");
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();
p.waitFor();
} catch (InterruptedException ie) {
throw new IOException("Error waiting for command " + ie.getMessage());
}
Porém quando executo o processo fica preso, não finaliza nunca.
root@ubuntu:/usr/local/bin# ps aux | grep pkpgcounter
tomcat6 18458 0.0 1.1 13400 5924 ? S 00:42 0:00 /usr/bin/python /usr/bin/pkpgcounter /root/t2.pdf
Se executo na unha, funciona:
root@ubuntu:/usr/local/bin# /usr/bin/pkpgcounter < /root/t2.pdf
22
Alguem saberia me ajudar?