stdin stdout的记录器

问题描述:

调试Emacs的外部进程处理我需要包装器来记录所有消息流。stdin stdout的记录器

因此Emacs发送字符串到包装stdin,包装器记录它并发送到外部进程。然后返回外部进程发送输出,包装器登录并发送给Emacs。

我的期望knowlage很小,所以我问问题。可能已经存在用于此目的的标准工具?

How to implement a stdin, stdout wrapper?不回答我的问题!

这个例子让我的魔杖,但在有限的形式(终端规范模式下配置,所以一些字符代码不容许):

 
#!/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 

我不了解情况。

是否通过stdin和stdout进行交互? tee(1)http://unixhelp.ed.ac.uk/CGI/man-cgi?tee是否不符合您的所有要求?

+0

我只可以说你不明白...看看http://www.nist.gov/el/msid/expect.cfm我找了已开发的解决方案,但似乎需要编写自己的。 – gavenkoa