ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> expect
expect
[Expect] End-of-line conventions on Expect for Windows
by Kenneth Jones other posts by this author
Sep 9 2007 6:41PM messages near this date
view in the new Beta List Site
Re: [Expect] GDB /windows | Re: [Expect] End-of-line conventions on Expect for Windows
Well, I'm finally getting a chance to play around with Expect for
Windows. I'd been far too busy with other projects to do much of a
comparison vs. the UNIX version before.

First challenge was successfully [spawn]ing telnet and driving it with
my script. Research brought me to David Gravereaux's recurring
instructions regarding DEP and dbghlp.dll. It seems to be such a
frequently asked question, and such a stumbling block for successfully
running many Expect for Windows scripts, I strongly suggest some note
in the documentation. I'd never even heard of DEP prior to this.

Armed with this information, I invested several hours, pulled much
hair (though I've still got plenty to spare), and rebooted half a
dozen or so times before finally convincing my system to let me change
the DEP setting and upgrade the DLL. Which meant that I finally could
test out my telnet and ssh scripts. And found the results puzzling.

I'm quite familiar with the various end-of-line conventions in Expect
on UNIX, brought about by the interactions with the pttys. But
especially considering that I know that Windows typically uses \r\n as
EOL, I was surprised that all of my scripts were receiving only \n as
EOL. I had test scripts connecting to a Tcl-based server running on
the same Windows system, and ssh'ing to a UNIX system. I tried driving
the interaction through an ssh client, Window's native telnet client,
and an all-Tcl telnet client. And the results were always that lines
received were terminated by \n, as reported by [exp_internal]
debugging.

So, is this typical and... um... expected behavior when using Expect
for Windows, or is it some odd configuration of my system that I'm
missing? In all of my research on the Tcl'ers Wiki, comp.lang.tcl, and
these email archives, I've not seen anyone else mention this behavior,
which I considered quite surprising. And could someone in the know
verify for me what the "standard" EOL should be for both [send]ing and
[expect]ing from both the console for user interaction and a spawned
process?

Overall, I'm looking to update my tutorial scripts to be platform
independent. And if what I observed is typical, I'm considering
techniques like this to handle either platform:

# Read a single line

expect -re {([^\r\n]*)\r?\n} {puts "Received: $expect_out(1,string)"}

# Or the non-greedy equivalent

expect -re {(.*?)\r?\n} {puts "Received: $expect_out(1,string)"}

Drawbacks? Comments? Suggestions? Cocktails?

-- 
Ken Jones, President
Avia Training and Consulting
www.avia-training.com
866-TCL-HELP (866-825-4357) US Toll Free
415-643-8692 Voice
415-643-8697 Fax
_______________________________________________
Expect mailing list
Expect@[...].com
http://listserv.ActiveState.com/mailman/listinfo/expect
Thread:
Kenneth Jones
David Gravereaux
Kenneth Jones

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved