The simplest way to interact from within bash with Caché looks like this:
csession TEST -U%SYS << EOF
... next line of your bash script ...
Output of Caché `write` and `zwrite` commands will go to STDOUT. As usual, you can redirect it wherever you want, e.g.
csession TEST -U%SYS << EOF >> /home/james/mysession.log
As parsing csession log can be a nasty task, I usually try to avoid it by construct: