* Debug technique for comint, need stdin/stdout logger.
@ 2011-09-07 14:32 Oleksandr Gavenko
2011-09-21 22:12 ` Oleksandr Gavenko
0 siblings, 1 reply; 2+ messages in thread
From: Oleksandr Gavenko @ 2011-09-07 14:32 UTC (permalink / raw)
To: help-gnu-emacs
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Debug technique for comint, need stdin/stdout logger.
2011-09-07 14:32 Debug technique for comint, need stdin/stdout logger Oleksandr Gavenko
@ 2011-09-21 22:12 ` Oleksandr Gavenko
0 siblings, 0 replies; 2+ messages in thread
From: Oleksandr Gavenko @ 2011-09-21 22:12 UTC (permalink / raw)
To: help-gnu-emacs
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-09-21 22:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-07 14:32 Debug technique for comint, need stdin/stdout logger Oleksandr Gavenko
2011-09-21 22:12 ` Oleksandr Gavenko
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.