# prolog scripting

**URL:** <https://community.unix.com/t/prolog-scripting/278318>\
**Category:** Shell Programming and Scripting\
**Created:** [December 1, 2010, 4:02pm UTC](https://community.unix.com/t/prolog-scripting/278318 "2010-12-01T16:02:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ghaith](https://community.unix.com/letter_avatar/ghaith/32/6_449c533f586939b6e5f246632a46421f.png) [@ghaith](https://community.unix.com/u/ghaith)\
**Post date:** [December 1, 2010, 4:02pm UTC](https://community.unix.com/t/prolog-scripting/278318/1 "2010-12-01T16:02:14Z")

</div>

I am running a tool in prolog and after the running is finished i have the fllowing result:

Graph Size statistics: Nodes = 1 Abstract Edges = 0 Cases = 1

-- Pruning outputs --

-- Print pruned output- (clock-2) MDGs options --  
No printing (Return) / Statistics only (%) /  
To screen (Space) / To file (FILE-NAME) :

pruned output- (clock-2)

t

Graph Size statistics: Nodes = 1 Abstract Edges = 0 Cases = 1

Error detected!

=== The Counterexample ===

-------- Assumptions --------

-------- Initial state --------  
input = z3  
nxa = 1  
reg\_output\_signal = 1

-------- Clock cycle 1 --------

-- The symbolic input --

t\_ls6 = 1  
glitch\_signal = dg  
select2 = 1

-- The symbolic state --

reg\_output\_signal = dgp

-------- Clock cycle 2 --------

-- The symbolic input --

-- Symbolic Output --

flag = 1

=== End of counterexample ===

Generating counter example took 0.040 seconds.

=== Property checking failed ===

=== Performance statistics ===

Compiling:  
Compiling individual components took: 0.300 seconds  
Building the transition relations took: 0.020 seconds  
Sub-total (component+transition relation): 0.320 seconds  
Compiling (loading+deriving all the relations) took: 0.530 seconds  
Garbage\_collection: 0.000 seconds  
Memory: 535924 bytes  
Nodes: 495; Abstract Edges: 1;

-- Detailed statistics --  
Run time: 0.530 seconds;  
System time: 0.020 seconds;  
Real time: 4.196 seconds

Virtual memory in use: 535924 bytes; Virtual memory free: -535924 bytes  
Program space: 142732 bytes  
Global stack memory: 393192 bytes; Local stack memory: 0 bytes  
Global stack in use: 763424 bytes; Global stack free: -461084 bytes  
Local stack in use: 604 bytes; Local stack free: -604 bytes  
Trail 200  
Garbage\_collection 0 times: 0.000 seconds; 0 bytes freed  
Global stack shift 0 times; Local stack shift 3 times; in 0.000 seconds  
Number of atoms: 6; Atom space in use: 216 bytes; free: -48 bytes  
Atom Garbage\_collection 0 times: 0.000 seconds; 0 bytes freed

Verification:  
Building initial state MDG took 0.010 seconds  
Computing reachable states took : 0.030 seconds  
Misc took : 0.060 seconds  
Sub-total (reachability analysis) : 0.090 seconds  
Verification (rechability analysis + init states generation) : 0.100 seconds  
Garbage\_collection: 0.020 seconds  
Memory: 68764 bytes  
Nodes: 169; Abstract edges : 0

but I only need the text in bold. so how can I copy it from prolog to another text file.

thanks

ghaith

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/6_449c533f586939b6e5f246632a46421f.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [December 1, 2010, 4:25pm UTC](https://community.unix.com/t/prolog-scripting/278318/2 "2010-12-01T16:25:37Z")

</div>

```nohighlight
#!/bin/sh

START="=== The Counterexample ==="
END="=== End of counterexample ==="
PRINTING=0

while read LINE
do
        if [["${PRINTING}" -eq 1]]
        then
                [["${LINE}" == "${END}"]] && exit 0
                echo "${LINE}"
        else
                [["${LINE}" == "${START}"]] && PRINTING=1
        fi
done

```

```nohighlight
$ ./between.sh < input > output

```

---

<div class="post-metadata">

**Author:** ![ghaith](https://community.unix.com/letter_avatar/ghaith/32/6_449c533f586939b6e5f246632a46421f.png) [@ghaith](https://community.unix.com/u/ghaith)\
**Post date:** [December 2, 2010, 9:47am UTC](https://community.unix.com/t/prolog-scripting/278318/3 "2010-12-02T09:47:27Z")

</div>

hi,  
thanks for replying,  
but to which file you are copying the data I mean what is the name of the output file.?

and I did not understand the following part and where should I but it:  
$ ./between.sh \< input \> output

thanks again,

Ghaith,

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/6_449c533f586939b6e5f246632a46421f.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [December 2, 2010, 12:24pm UTC](https://community.unix.com/t/prolog-scripting/278318/4 "2010-12-02T12:24:11Z")

</div>

> [@ghaith](#):
>
> hi,  
> thanks for replying,  
> but to which file you are copying the data I mean what is the name of the output file.?

The output file is called 'output'.

> [@](#):
>
> and I did not understand the following part and where should I put it:

In the shell. The script I gave you should be saved into a file named between.sh, and set executable with 'chmod +x'. Once that's done you can run it in the shell to process files like:

```plaintext
./between.sh < input > output

```

substitute the filenames you want, but the \< \> aren't decorations, they open files for input and output.

---

<div class="post-metadata">

**Author:** ![ghaith](https://community.unix.com/letter_avatar/ghaith/32/6_449c533f586939b6e5f246632a46421f.png) [@ghaith](https://community.unix.com/u/ghaith)\
**Post date:** [December 2, 2010, 3:40pm UTC](https://community.unix.com/t/prolog-scripting/278318/5 "2010-12-02T15:40:33Z")

</div>

the problem here is the result is not in file it is on show in screen so I need some kind of command to copy it from prolog.

thanks,

---

<div class="post-metadata">

**Author:** ![Corona688](https://community.unix.com/letter_avatar/corona688/32/6_449c533f586939b6e5f246632a46421f.png) [@Corona688](https://community.unix.com/u/Corona688)\
**Post date:** [December 3, 2010, 5:32pm UTC](https://community.unix.com/t/prolog-scripting/278318/6 "2010-12-03T17:32:49Z")

</div>

> [@ghaith](#):
>
> the problem here is the result is not in file it is on show in screen

So redirect its output into a file using the same syntax I just did above.

```plaintext
$ program_that_runs_prolog_code < input > output

```

or you could just pipe it into the program directly.

```plaintext
$ program_that_runs_prolog_code | ./between.sh

```
