Pergunta

I want to run swipl prolog through command prompt,I want to read input.txt as a query file and want to output result to output.txt

My command line command:

swipl -f asd.pl < input.txt > output.txt

But my output result is comming on command prompt and getting blank output.txt file.

Foi útil?

Solução

It's working right for me. Are you sure you are not receiving errors on command prompt ? Note: to output stderr you should use 2> filename

Example (test.pl):

:- initialization(main).

main:-
  repeat,
    read(Term),
     writeln(term(Term)),
    Term=end_of_file -> halt, fail.


swipl.exe -f test.pl < test.pl > test.txt  2> stderr.txt

writes on test.txt:

term((:-initialization main))
term((main:-repeat,read(_G747),writeln(term(_G747)),_G747=end_of_file->halt,fail))
term(end_of_file)

and on stderr.txt:

% c:/swi/workspace/test.pl compiled 0.00 sec, 4 clauses
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top