To debug external process handling by Emacs I need wrapper which log all message flow.
So Emacs send string to wrapper stdin, wrapper log it and send to external process. Then back external process send output, wrapper log in and send to Emacs.
My Expect knowlage is small so I ask question. May be already exist standard tools for this purpose?
How to implement a stdin, stdout wrapper? is not answer to my question!!
This example make that I wand but in limited form (terminal configured in canonical mode, so some char code don’t allowed):
#!/usr/bin/env expect set in [open in.log w] set out [open out.log w] log_user 0 set stty_init {-echo} exp_internal 1 # spawn sort spawn /bin/prog set proc_id $spawn_id expect { -i $user_spawn_id -re . { puts -nonewline $in $expect_out(buffer) send -i $proc_id $expect_out(buffer) exp_continue } eof { send -i $proc_id \x04 sleep 1 send -i $proc_id \x04 expect -i $proc_id -re . { puts -nonewline $out $expect_out(buffer) send_user $expect_out(buffer) exp_continue } eof { } } -i $proc_id -re . { puts -nonewline $out $expect_out(buffer) send_user $expect_out(buffer) exp_continue } eof { } } wait