开发者

Logger for stdin stdout

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 s开发者_高级运维tdin, stdout wrapper? is not answer to my question!!


I don't understand the situation.

Is the interaction all through stdin and stdout? Does tee(1) http://unixhelp.ed.ac.uk/CGI/man-cgi?tee not meet all your requirements?


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜