Search code examples
javabashunixanswer-set-programming

Problems when running an ASP program from a Java program using Runtime.exec()


So the problem that I am having is that I can't get a ASP program to execute fully when run using a bash script. So the script runs the ASP but only starts, it never completes.

So my question is how to make clingo fully execute when using bash

bash -c clingo -n 1 <File Path>

This line in a normal terminal simply gives

clingo version 4.5.4

And then holds there without completing.

I think my issue is todo with my understanding of how bash runs/executes things so any help would be greatly appreciated.

Edit:

It should be noted that when interrupted clingo tells me that there has been zero CPU time, so it isn't doing anything. I know this asp works and gives plenty of results just not when run with bash.

^C*** Info : (clingo): INTERRUPTED by signal!
UNKNOWN

INTERRUPTED  : 1
Models       : 0+    
Calls        : 1
Time         : 164.667s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s)
CPU Time     : 0.000s

Solution

  • You are requesting to execute clingo without command-line options, thus clingo reads from stdin. The -n 1 ... options are passed on to bash. Pass the -c parameter as string like this:

    bash -c 'clingo -n 1 ...'