Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Debug technique for comint, need stdin/stdout logger.

10 views
Skip to first unread message

Oleksandr Gavenko

unread,
Sep 7, 2011, 10:32:53 AM9/7/11
to help-gn...@gnu.org
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.


0 new messages