Message from discussion
Debug technique for comint, need stdin/stdout logger.
Path: g2news2.google.com!news1.google.com!news.glorb.com!usenet.stanford.edu!not-for-mail
From: Oleksandr Gavenko <gave...@bifit.com.ua>
Newsgroups: gnu.emacs.help
Subject: Debug technique for comint, need stdin/stdout logger.
Date: Wed, 07 Sep 2011 17:32:53 +0300
Lines: 66
Approved: help-gnu-em...@gnu.org
Message-ID: <mailman.2772.1315406000.939.help-gnu-emacs@gnu.org>
NNTP-Posting-Host: lists.gnu.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: usenet.stanford.edu 1315406001 18639 140.186.70.17 (7 Sep 2011 14:33:21 GMT)
X-Complaints-To: action@cs.stanford.edu
To: help-gnu-em...@gnu.org
Envelope-to: help-gnu-em...@gnu.org
X-Injected-Via-Gmane: http://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-em...@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Users list for the GNU Emacs text editor <help-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/help-gnu-emacs>,
<mailto:help-gnu-emacs-requ...@gnu.org?subject=unsubscribe>
List-Archive: </archive/html/help-gnu-emacs>
List-Post: <mailto:help-gnu-em...@gnu.org>
List-Help: <mailto:help-gnu-emacs-requ...@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/help-gnu-emacs>,
<mailto:help-gnu-emacs-requ...@gnu.org?subject=subscribe>
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.