From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Oleksandr Gavenko Newsgroups: gmane.emacs.help Subject: Re: Debug technique for comint, need stdin/stdout logger. Date: Thu, 22 Sep 2011 01:12:55 +0300 Message-ID: References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: dough.gmane.org 1316643208 22249 80.91.229.12 (21 Sep 2011 22:13:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 21 Sep 2011 22:13:28 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Sep 22 00:13:25 2011 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R6V2i-0008OI-QF for geh-help-gnu-emacs@m.gmane.org; Thu, 22 Sep 2011 00:13:24 +0200 Original-Received: from localhost ([::1]:38415 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6V2i-0003PX-6m for geh-help-gnu-emacs@m.gmane.org; Wed, 21 Sep 2011 18:13:24 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:57330) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6V2c-0003Iu-Eo for help-gnu-emacs@gnu.org; Wed, 21 Sep 2011 18:13:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R6V2b-0006wz-IL for help-gnu-emacs@gnu.org; Wed, 21 Sep 2011 18:13:18 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:60127) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R6V2b-0006wj-3z for help-gnu-emacs@gnu.org; Wed, 21 Sep 2011 18:13:17 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1R6V2Z-0008Kh-QT for help-gnu-emacs@gnu.org; Thu, 22 Sep 2011 00:13:15 +0200 Original-Received: from 160-37-202-46.pool.ukrtel.net ([46.202.37.160]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 22 Sep 2011 00:13:15 +0200 Original-Received: from gavenkoa by 160-37-202-46.pool.ukrtel.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 22 Sep 2011 00:13:15 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 57 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 160-37-202-46.pool.ukrtel.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.1) Gecko/20110830 Thunderbird/6.0.1 In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 80.91.229.12 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:82276 Archived-At: 07.09.2011 17:32, Oleksandr Gavenko пишет: > When work with Emacs comint I need logger for stdin/stdout process > interaction. > > So I change name of calling program in Emacs > and that logger/script call original command and log > stdin and stdout to files. > > I try write expect script: > ... I get working one. It is used to debug interaction with Cygwin Python in 'python-mode'. Expect come with all Linuxes and available under Cygwin... #!/usr/bin/env expect set in [open logger_in.log w] set out [open logger_out.log w] set timeout 3600 log_user 0 set stty_init {-echo} # exp_internal 1 set cli [open logger_cli.log w] foreach arg "$argv" { puts $cli $arg } close $cli eval spawn python2.6.exe $argv set proc_id $spawn_id expect { -i $user_spawn_id -re (.+)\r?\n { puts -nonewline $in $expect_out(buffer) send -i $proc_id $expect_out(1,string)\n 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 { } } close $in close $out wait