all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Tennis Smith" <tennis_smith@yahoo-remove-to-reply.com>
Subject: Re: Help - Tcl/Expect Parsing Strangeness In Emacs Shell
Date: Tue, 17 Aug 2004 08:53:05 -0700	[thread overview]
Message-ID: <1092757754.574032@sj-nntpcache-5> (raw)
In-Reply-To: s6aisbhu96c.fsf@peace.mel.nist.gov

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.

  reply	other threads:[~2004-08-17 15:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-08-16 18:21 Tennis Smith

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1092757754.574032@sj-nntpcache-5 \
    --to=tennis_smith@yahoo-remove-to-reply.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.