2

To excecute SENNA in the terminal I use the command:

senna.exe < input.txt > result.txt

Now I want to realize this in a java program. This is my code so far

ProcessBuilder builder = new ProcessBuilder("senna.exe");
builder.redirectErrorStream(true);
Process process = builder.start();
OutputStream stdin = process.getOutputStream();
InputStream stdout = process.getInputStream();

BufferedReader reader = new BufferedReader (new InputStreamReader(stdout));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stdin));

writer.write("This is a test sentence");;
writer.flush();
String line;
while ((line = reader.readLine ()) != null) {
    System.out.println ("Stdout: " + line);
}

To redirect the input, output and error stream I used the code from this thread. The problem is that I get the following error message:

FATAL ERROR: unable to open file hash/words.lst

Am I doing something wrong?

Community
  • 1
  • 1
ckmk14
  • 99
  • 1
  • 1
  • 10

2 Answers2

0

From the examples you've given it seems that you're adapting Linux code from this thread to run on Windows with senna.exe.

From the error you're getting it seems that you forgot to change Linux's forward slash (/) to Windows' backslash (\).

Try changing your filepath's forwardslash to backslash.

Community
  • 1
  • 1
João Neves
  • 944
  • 1
  • 13
  • 18
0

As far as I can see, you haven't set the directory path to ProcessBuilder object. This error seems to be because there is a folder called 'hash' in senna folder which can't be reached.

Please try this: builder.directory(new File("/yourpathtosenna/senna/")); (I am on a linux machine)

Your error should most probably change, but I am not sure if you will get the output as I am also struggling with running senna interactively through Java on a Linux machine at the moment.

Good luck and do update if you are successful!

Varda
  • 69
  • 4
  • 13