* Help - Tcl/Expect Parsing Strangeness In Emacs Shell
@ 2004-08-16 23:00 Tennis Smith
2004-08-17 14:32 ` Don Libes
0 siblings, 1 reply; 4+ messages in thread
From: Tennis Smith @ 2004-08-16 23:00 UTC (permalink / raw)
Hi,
Apologies for the wide distribution. This is in one of those grey areas
between tools so I'm not sure where it fits. I tried posting this once
before
with a "tar" file containing my test scripts, but the mailer barfed back at
me.
The problem is that in certain circumstances, Tcl/Expect doesn't work
correctly
while in an Emacs shell. Application output that Expect is "expecting"
will not be detected.
I ran into this while trying to parse the output of a telnet session to an
MS
Windows machine. Initially, I thought it was something wrong with the
Windows output (or with your humble programmer ;-)). But after much
debugging, I've narrowed it down to two salient facts:
1 - Everything works correctly on rxvt, xterm and Emacs version
20.7.1 and earlier.
2 - The only environment that consistently has this occur is Emacs versions
21.2.95.2 and later.
Steps To Recreate:
Below are two tiny scripts.
The "test.exp" script spawns a task. The "datagen.tcl" script is
called in the spawned task and simply writes to the screen. The "test.exp"
then reads output from "datagen.tcl" Run the "test.exp" script with the
"datagen.tcl" script in the same directory.
When everything is working _correctly_, you'll see two copies of command
output from "datagen.tcl", one from stdout and one printed from expect
itself.
If run under an xterm, expect will be able to detect output and put it into
the "accum" variable (which is then printed). But, if run in a shell under
Emacs, expect will not detect the data and will put only blank lines into
the "accum" variable.
Has anyone else seen this or know how to fix it?
TIA,
-Tennis
#!/bin/sh
#
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x
set starter { ${1:+"$@"}
shift
shift
exec expect -f $0 -- ${1:+"$@"}
}
#
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x
#
# Ive tried this test under tcsh and bash. Both have the same
# result.
#
puts ">>>>>>>>BEGIN VERSION INFO<<<<<<<<<<\
\nTCL VERSION:\ntcl version [info tclversion]\n\
\nEXPECT VERSION:\n[exec expect -v]\n\
\nBASH Version:\n[exec bash --version]\n\
\nTCSH Version:\n [exec tcsh --version]\n\
\n>>>>>>>END VERSION INFO<<<<<<<<<<<<<<\n\n"
spawn bash
exp_send "./datagen.tcl\n"
set accum {}
expect {
-re " " {
set accum "${accum}$expect_out(buffer)"
exp_continue
}
timeout {
if {![string length $expect_out(buffer)]} {
set accum "timed out waiting for data"
} else {
set accum "${accum}\n\nFinal timeout\n"
}
}
}
puts "accum:$accum"
# End of test.exp
#!/bin/sh
#
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x
set starter { ${1:+"$@"}
shift
shift
exec expect -f $0 -- ${1:+"$@"}
}
#
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
x
puts "ipconfig\
\n\nWindows 2000 IP Configuration\
\n\nEthernet adapter 126 Network:\
\n\n Connection-specific DNS Suffix . : \
\n IP Address. . . . . . . . . . . . : 0.0.0.0\
\n Subnet Mask . . . . . . . . . . . : 0.0.0.0\
\n Default Gateway . . . . . . . . . : \
\n\nEthernet adapter 172 Network:\
\n\n Connection-specific DNS Suffix . : \
\n IP Address. . . . . . . . . . . . : 172.19.178.242\
\n Subnet Mask . . . . . . . . . . . : 255.255.255.0\
\n Default Gateway . . . . . . . . . : 172.19.178.1"
# End of datagen.tcl
--
Remove "-remove-to-reply" to respond to my email address directly.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Help - Tcl/Expect Parsing Strangeness In Emacs Shell
2004-08-16 23:00 Help - Tcl/Expect Parsing Strangeness In Emacs Shell Tennis Smith
@ 2004-08-17 14:32 ` Don Libes
2004-08-17 15:53 ` Tennis Smith
0 siblings, 1 reply; 4+ messages in thread
From: Don Libes @ 2004-08-17 14:32 UTC (permalink / raw)
Emacs plays around with tty settings in a way that can break
simplistic Expect scripts. Have you read the Expect man page - it
talks about this and how to avoid it. The Expect book has a section
that describes the same thing albeit in a different way.
Don
"Tennis Smith" <tennis_smith@yahoo-remove-to-reply.com> writes:
> Hi,
>
> Apologies for the wide distribution. This is in one of those grey areas
> between tools so I'm not sure where it fits. I tried posting this once
> before
> with a "tar" file containing my test scripts, but the mailer barfed back at
> me.
>
> The problem is that in certain circumstances, Tcl/Expect doesn't work
> correctly
> while in an Emacs shell. Application output that Expect is "expecting"
> will not be detected.
>
> I ran into this while trying to parse the output of a telnet session to an
> MS
> Windows machine. Initially, I thought it was something wrong with the
> Windows output (or with your humble programmer ;-)). But after much
> debugging, I've narrowed it down to two salient facts:
>
> 1 - Everything works correctly on rxvt, xterm and Emacs version
> 20.7.1 and earlier.
>
> 2 - The only environment that consistently has this occur is Emacs versions
> 21.2.95.2 and later.
>
> Steps To Recreate:
>
> Below are two tiny scripts.
>
> The "test.exp" script spawns a task. The "datagen.tcl" script is
> called in the spawned task and simply writes to the screen. The "test.exp"
> then reads output from "datagen.tcl" Run the "test.exp" script with the
> "datagen.tcl" script in the same directory.
>
> When everything is working _correctly_, you'll see two copies of command
> output from "datagen.tcl", one from stdout and one printed from expect
> itself.
>
> If run under an xterm, expect will be able to detect output and put it into
> the "accum" variable (which is then printed). But, if run in a shell under
> Emacs, expect will not detect the data and will put only blank lines into
> the "accum" variable.
>
> Has anyone else seen this or know how to fix it?
>
> TIA,
> -Tennis
>
> #!/bin/sh
> #
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> x
> set starter { ${1:+"$@"}
> shift
> shift
> exec expect -f $0 -- ${1:+"$@"}
> }
> #
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> x
> #
> # Ive tried this test under tcsh and bash. Both have the same
> # result.
> #
> puts ">>>>>>>>BEGIN VERSION INFO<<<<<<<<<<\
> \nTCL VERSION:\ntcl version [info tclversion]\n\
> \nEXPECT VERSION:\n[exec expect -v]\n\
> \nBASH Version:\n[exec bash --version]\n\
> \nTCSH Version:\n [exec tcsh --version]\n\
> \n>>>>>>>END VERSION INFO<<<<<<<<<<<<<<\n\n"
> spawn bash
> exp_send "./datagen.tcl\n"
> set accum {}
> expect {
> -re " " {
> set accum "${accum}$expect_out(buffer)"
> exp_continue
> }
> timeout {
> if {![string length $expect_out(buffer)]} {
> set accum "timed out waiting for data"
> } else {
> set accum "${accum}\n\nFinal timeout\n"
> }
> }
> }
> puts "accum:$accum"
>
> # End of test.exp
>
>
> #!/bin/sh
> #
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> x
> set starter { ${1:+"$@"}
> shift
> shift
> exec expect -f $0 -- ${1:+"$@"}
> }
> #
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> x
> puts "ipconfig\
> \n\nWindows 2000 IP Configuration\
> \n\nEthernet adapter 126 Network:\
> \n\n Connection-specific DNS Suffix . : \
> \n IP Address. . . . . . . . . . . . : 0.0.0.0\
> \n Subnet Mask . . . . . . . . . . . : 0.0.0.0\
> \n Default Gateway . . . . . . . . . : \
> \n\nEthernet adapter 172 Network:\
> \n\n Connection-specific DNS Suffix . : \
> \n IP Address. . . . . . . . . . . . : 172.19.178.242\
> \n Subnet Mask . . . . . . . . . . . : 255.255.255.0\
> \n Default Gateway . . . . . . . . . : 172.19.178.1"
> # End of datagen.tcl
>
> --
> Remove "-remove-to-reply" to respond to my email address directly.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Help - Tcl/Expect Parsing Strangeness In Emacs Shell
2004-08-17 14:32 ` Don Libes
@ 2004-08-17 15:53 ` Tennis Smith
0 siblings, 0 replies; 4+ messages in thread
From: Tennis Smith @ 2004-08-17 15:53 UTC (permalink / raw)
Hi Don,
Thanks for the reply. The man page pointer helps.
I'm thinking now that shell handling in Emacs is the culprit. As I said
below, this used to work fine in Emacs 20. It doesn't work in Emacs 21.
Emacs has lost functionality that used to be there. I don't think its
Expect's problem.
-Tennis
"Don Libes" <libes@nist.gov> wrote in message
news:s6aisbhu96c.fsf@peace.mel.nist.gov...
> Emacs plays around with tty settings in a way that can break
> simplistic Expect scripts. Have you read the Expect man page - it
> talks about this and how to avoid it. The Expect book has a section
> that describes the same thing albeit in a different way.
>
> Don
>
> "Tennis Smith" <tennis_smith@yahoo-remove-to-reply.com> writes:
>
> > Hi,
> >
> > Apologies for the wide distribution. This is in one of those grey areas
> > between tools so I'm not sure where it fits. I tried posting this once
> > before
> > with a "tar" file containing my test scripts, but the mailer barfed
back at
> > me.
> >
> > The problem is that in certain circumstances, Tcl/Expect doesn't work
> > correctly
> > while in an Emacs shell. Application output that Expect is "expecting"
> > will not be detected.
> >
> > I ran into this while trying to parse the output of a telnet session to
an
> > MS
> > Windows machine. Initially, I thought it was something wrong with the
> > Windows output (or with your humble programmer ;-)). But after much
> > debugging, I've narrowed it down to two salient facts:
> >
> > 1 - Everything works correctly on rxvt, xterm and Emacs version
> > 20.7.1 and earlier.
> >
> > 2 - The only environment that consistently has this occur is Emacs
versions
> > 21.2.95.2 and later.
> >
> > Steps To Recreate:
> >
> > Below are two tiny scripts.
> >
> > The "test.exp" script spawns a task. The "datagen.tcl" script is
> > called in the spawned task and simply writes to the screen. The
"test.exp"
> > then reads output from "datagen.tcl" Run the "test.exp" script with the
> > "datagen.tcl" script in the same directory.
> >
> > When everything is working _correctly_, you'll see two copies of
command
> > output from "datagen.tcl", one from stdout and one printed from expect
> > itself.
> >
> > If run under an xterm, expect will be able to detect output and put it
into
> > the "accum" variable (which is then printed). But, if run in a shell
under
> > Emacs, expect will not detect the data and will put only blank lines
into
> > the "accum" variable.
> >
> > Has anyone else seen this or know how to fix it?
> >
> > TIA,
> > -Tennis
> >
> > #!/bin/sh
> > #
> >
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > x
> > set starter { ${1:+"$@"}
> > shift
> > shift
> > exec expect -f $0 -- ${1:+"$@"}
> > }
> > #
> >
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > x
> > #
> > # Ive tried this test under tcsh and bash. Both have the same
> > # result.
> > #
> > puts ">>>>>>>>BEGIN VERSION INFO<<<<<<<<<<\
> > \nTCL VERSION:\ntcl version [info tclversion]\n\
> > \nEXPECT VERSION:\n[exec expect -v]\n\
> > \nBASH Version:\n[exec bash --version]\n\
> > \nTCSH Version:\n [exec tcsh --version]\n\
> > \n>>>>>>>END VERSION INFO<<<<<<<<<<<<<<\n\n"
> > spawn bash
> > exp_send "./datagen.tcl\n"
> > set accum {}
> > expect {
> > -re " " {
> > set accum "${accum}$expect_out(buffer)"
> > exp_continue
> > }
> > timeout {
> > if {![string length $expect_out(buffer)]} {
> > set accum "timed out waiting for data"
> > } else {
> > set accum "${accum}\n\nFinal timeout\n"
> > }
> > }
> > }
> > puts "accum:$accum"
> >
> > # End of test.exp
> >
> >
> > #!/bin/sh
> > #
> >
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > x
> > set starter { ${1:+"$@"}
> > shift
> > shift
> > exec expect -f $0 -- ${1:+"$@"}
> > }
> > #
> >
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> > x
> > puts "ipconfig\
> > \n\nWindows 2000 IP Configuration\
> > \n\nEthernet adapter 126 Network:\
> > \n\n Connection-specific DNS Suffix . : \
> > \n IP Address. . . . . . . . . . . . : 0.0.0.0\
> > \n Subnet Mask . . . . . . . . . . . : 0.0.0.0\
> > \n Default Gateway . . . . . . . . . : \
> > \n\nEthernet adapter 172 Network:\
> > \n\n Connection-specific DNS Suffix . : \
> > \n IP Address. . . . . . . . . . . . : 172.19.178.242\
> > \n Subnet Mask . . . . . . . . . . . : 255.255.255.0\
> > \n Default Gateway . . . . . . . . . : 172.19.178.1"
> > # End of datagen.tcl
> >
> > --
> > Remove "-remove-to-reply" to respond to my email address directly.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Help - Tcl/Expect Parsing Strangeness In Emacs Shell
@ 2004-08-16 18:21 Tennis Smith
0 siblings, 0 replies; 4+ messages in thread
From: Tennis Smith @ 2004-08-16 18:21 UTC (permalink / raw)
Hi,
Apologies for the wide distribution. This is in one of those grey areas
between tools so I'm not sure where it fits.
Basically, in certain circumstances, Tcl/Expect doesn't seem to work
correctly while in a tcsh/bash shell under Emacs. Application output that
Expect is "expecting" will not be detected.
I ran into this while trying to parse the output of a telnet session to a MS
Windows machine. Initially, I thought it was something wrong with the
Windows output (or with your humble programmer ;-)). During debugging, I've
winnowed out the various Windows and networking components . Now I can
recreate it at will on Solaris and Linux with no telnet/Windows involvement.
By contrast, everything works correctly on rxvt, xterm and Emacs version
20.7.1 and earlier.
The only environment that consistently has this occur is Emacs versions
21.2.95.2 and later. In addition, this only happens parsing strings with
"tabs" (0x09) frequently used.
How to observe/recreate:
Attached, is tar file with two tiny scripts that illustrate the problem.
After uncompress/untar, run the "test.exp" script. The "test.exp" script
spawns a task that will print a reproduction of a command output. When
everything is working correctly, you'll see two copies of the command
output, one from stdout and one printed from expect itself.
If run under an xterm, expect will be able to detect output and put it into
the "accum" variable (which is then printed). But, if run in a shell under
Emacs (tcsh or bash in my case), expect will not detect the data and will
put only blank lines into the "accum" variable.
Has anyone else seen this?
TIA,
-Tennis
begin 666 exptest.tar.Z
M'YV0+EZ4P0.'3IDY=%X`6,BPH<.'$"-*G$BQ8D48,&C N%&C!@",-&K Z/@1
M(\89,4J:7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\NO$6&R"$+<<<1(*P!6IFO#$V
M7+KS3F 7) ;->A%80%'$$%3$[CGH3M2^A=+@$20>>G8@SZ#R"PH1Q!1(;)ZB
M\6Y8C_W=<Z=7/)'>JV[T@JZ3;_[N1-;N._9RHX%>"^\[7O)6MR#*3:X(3B""
M]&8G.B>0#G40A"")W. NWL A#'=P@]WPEA^R?*$W=1-!0-"B%K:XP2UP65 %
M>_.;,(QA#'5H@\Z>HP"F_68/^3%:"\3TGQ[B<'7889$+82C#Y>QAB#'L`PEL
M^(4W\ <%8IA5BE+@+B!RAR!?&)#M4%.'PQF-AD93E>&<>$/E18<Z.@O!%A!2
MMJN @ V;Z=L2M9>J)CXQBE.:8A?ZH#,S`I&%+7IA#)DB`C&>#01D!,&CTJ J
M-P9O*20,0Q6MR,<RL*$W?;3BZ@")Q"(:IY-]F* 14!,&W!F2C"KT(PB>\T4%
MT' __?E/)W5 @DZZ*V6XS*4N=\G+7OKRE\ ,IC"'2<QB&O.8R$RF,I?)S&8Z
M\YG0C*8TITG-:EKSFMC,IC:WR<UN>O.;X RG.,=)SG*:\YSH3*<ZU\G.=KKS
<G?",ISSG2<]ZVO.>^,RG/O?)SW[Z\Y\`#:@U`0``
`
end
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2004-08-17 15:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-16 23:00 Help - Tcl/Expect Parsing Strangeness In Emacs Shell Tennis Smith
2004-08-17 14:32 ` Don Libes
2004-08-17 15:53 ` Tennis Smith
-- strict thread matches above, loose matches on Subject: below --
2004-08-16 18:21 Tennis Smith
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.