Running the following code works fine on my pc but doesn't when run by nginx-clojure on my server.
ProcessBuilder pb = new ProcessBuilder("/usr/bin/vorbiscomment", "-w", "-t", "\"title=MySong\"", "-t", "\"artist=SomeArtist\"", "\"/media/music/SomeArtist/MySong.ogg\"");
Background:
I am working on a REST API for a music related project. It's using an nginx module (nginx-clojure) for embedding Java programs. My aim right now is to edit vorbis-tags utilising the unix commandline utility vorbiscomment and Java ProcessBuilder. The code does work on my pc, which makes me believe that it might have something to do with permissions on the server. My problem is that I'm not getting any output from the ProcessBuilder indicating that the command failed. I tried:
Process proc = pb.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
StringBuilder sb = new StringBuilder();
String line;
while ((line = reader.readLine()) != null)
{
sb.append(line).append('\n');
}
return sb.toString();
which didn't output anything.
I'd appreciate any help.
You are reading from the Process
's InputStream. You should be looking at
Process.getErrorStream()
or Process.getOutputStream()
.
https://docs.oracle.com/javase/7/docs/api/java/lang/Process.html
You could also inspect the exitValue to see if the process successfully completed.