Note that the output from put/2 is usually buffered, and is only output to the stream when the output is flushed (e.g. using flush/1).
Character codes for the non-printable characters (i.e. control characters) are also acceptable.
Success:
?- put(output, 0'a).
a
yes.
?- sh('cat file1').
a
yes.
?- open(file1,read,s1),
open(file2,write,s2),repeat,
( at_eof(s1) ->
!,
flush(s2),
close(s1),close(s2)
;
get(s1,Char),
put(s2,Char),
fail
).
Char = _g72
yes.
?- sh('cat file2').
a
yes.
Error:
put(output,A). (Error 4).
put(Stream,98). (Error 4).
put(output, '98'). (Error 5).
put(output, 98.0). (Error 5).
put("string" A). (Error 5).
put(11,97). (Error 192). % stream not open
put(atom,97). (Error 193).