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: Debug technique for comint, need stdin/stdout logger. Date: Wed, 07 Sep 2011 17:32:53 +0300 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1315406007 14411 80.91.229.12 (7 Sep 2011 14:33:27 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 7 Sep 2011 14:33:27 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Sep 07 16:33:24 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 1R1JBr-0007He-Rp for geh-help-gnu-emacs@m.gmane.org; Wed, 07 Sep 2011 16:33:24 +0200 Original-Received: from localhost ([::1]:42691 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1JBr-0000Aj-C5 for geh-help-gnu-emacs@m.gmane.org; Wed, 07 Sep 2011 10:33:23 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:54371) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1JBh-0000Aa-N6 for help-gnu-emacs@gnu.org; Wed, 07 Sep 2011 10:33:19 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R1JBc-0008WH-3h for help-gnu-emacs@gnu.org; Wed, 07 Sep 2011 10:33:13 -0400 Original-Received: from lo.gmane.org ([80.91.229.12]:39072) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1JBb-0008W8-Pa for help-gnu-emacs@gnu.org; Wed, 07 Sep 2011 10:33:07 -0400 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1R1JBa-00075Z-OW for help-gnu-emacs@gnu.org; Wed, 07 Sep 2011 16:33:06 +0200 Original-Received: from 91.193.68.214 ([91.193.68.214]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 07 Sep 2011 16:33:05 +0200 Original-Received: from gavenko by 91.193.68.214 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 07 Sep 2011 16:33:05 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 64 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 91.193.68.214 User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 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 X-Spam-Report: 5.4 points; * -0.0 SPF_PASS SPF: sender matches SPF record * 4.0 RCVD_NUMERIC_HELO Received: contains an IP address used for HELO * -2.6 BAYES_00 BODY: Bayesian spam probability is 0 to 1% * [score: 0.0000] * 4.0 RCVD_IN_SBL RBL: Received via a relay in Spamhaus SBL * [91.193.68.214 listed in zen.spamhaus.org] Xref: news.gmane.org gmane.emacs.help:82176 Archived-At: 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: #!/usr/bin/env expect set in [open in.log w] set out [open out.log w] log_user 0 spawn sort set proc_id $spawn_id stty -echo expect { -i $user_spawn_id -re . { puts -nonewline $in $expect_out(buffer) send -i $proc_id $expect_out(buffer) exp_continue } eof { } -i $proc_id -re . { puts -nonewline $out $expect_out(buffer) send_user $expect_out(buffer) exp_continue } eof { } } expect -i $proc_id -re . { puts -nonewline $out $expect_out(buffer) send_user $expect_out(buffer) exp_continue } eof { } close $in close $out but this is my first serious Expect script and it works bad: $ printf 'b\nquit\na\n' | ./logger.exp; \ printf '\n===in===\n'; cat in.log; \ printf '\n===out===\n'; cat out.log b quit a C-c C-c # I type C-c ===in=== b quit a ===out=== b quit # Why not sorted??? a Are there any program that do this job or please help fix this script.