Python & Expect

J

Jeff Wagner

Is there an Expect-like module for Python that is cross platform and, for the most part, does what
Expect does? A number of years ago, I wrote some Tcl scripts using Expect for automation. I am
trying to convince my good friend who I worked with at the time to try Python. He said, "what about
Expect?"

I have heard of a Pexpect but was told that it didn't run on win32 and he needs win32 and Linux
support both.

Thanks,
Jeff
 
P

Peter Hansen

Jeff said:
Is there an Expect-like module for Python that is cross platform and, for the most part, does what
Expect does? A number of years ago, I wrote some Tcl scripts using Expect for automation. I am
trying to convince my good friend who I worked with at the time to try Python. He said, "what about
Expect?"

I have heard of a Pexpect but was told that it didn't run on win32 and he needs win32 and Linux
support both.

Hmmm... let's see what Google brings up... (typing)

http://www.google.com/search?q=python+expect

Wow! Look at that! Pexpect is the first hit. Let's try accessing that
page and see what it says. (click) Ah, there's a "Requirements" link: (click)

--------------------------------------------
Python
Pexpect was written and tested with Python 2.1. It should work on earlier versions
that have the pty module. ...

pty module
Any POSIX system (UNIX) with a working pty module should be able to run Pexpect.
The pty module is part of the Standard Python Library, so if you are running on
a POSIX system you should have it. The pty module does not run as well on all platforms.
I have taken effort to try to smooth the wrinkles out the different platforms. To
learn more about the wrinkles see Bugs and Testing.

Pexpect does not currently work on the standard Windows Python(see the pty requirement);
however, it seems to work fine using Cygwin. ...
 
J

Jeff Wagner

Hmmm... let's see what Google brings up... (typing)

http://www.google.com/search?q=python+expect

Wow! Look at that! Pexpect is the first hit. Let's try accessing that
page and see what it says. (click) Ah, there's a "Requirements" link: (click)

--------------------------------------------
Python
Pexpect was written and tested with Python 2.1. It should work on earlier versions
that have the pty module. ...

pty module
Any POSIX system (UNIX) with a working pty module should be able to run Pexpect.
The pty module is part of the Standard Python Library, so if you are running on
a POSIX system you should have it. The pty module does not run as well on all platforms.
I have taken effort to try to smooth the wrinkles out the different platforms. To
learn more about the wrinkles see Bugs and Testing.

Pexpect does not currently work on the standard Windows Python(see the pty requirement);
however, it seems to work fine using Cygwin. ...

--------------------------------------------

Okay, Jeff, consider your wrist slapped for not even trying... :)

-Peter

Ouch ;)

Ok, I did look at it and mentioned in my post that Pexpect doesn't run on win32. The question was,
is there a Expect-like module that does run on win32. I couldn't find one.

Jeff
 
C

Cameron Laird

.
.
. .
.
.
Ok, I did look at it and mentioned in my post that Pexpect doesn't run
on win32. The question was,
is there a Expect-like module that does run on win32. I couldn't find one.

Jeff

Yes and no.

I could write a book on that one question--in fact, I've given
serious thought to the possibility. The basic answer is, no,
but there are at least a half-dozen qualifications to that.

The answer to, "What about Expect?" is this: it's a wonderful
application, with all sorts of virtues--but it is NOT effec-
tively available for Windows. So, in deciding between Python
and Tcl, if the requirement is for a current Expect-like thing,
Tcl has no particular advantage over Python, 'cause they both
depend, at least for now, on POSIXy ptys.

I think Expect and Tcl quite valuable; I use 'em all the time.
HOWEVER, along with understanding the lack of portability of
the pty abstraction to Windows, the second crucial fact you
deserve to know is that Expect is far less necessary for most
people than it used to be, or than they persist in thinking it
is now. You can automate telnet, FTP, SMTP, and much else,
without recourse to Expect.

As is so often the case, the best advice I know is to take a
little time and think over your true requirements again.
 
L

Luther Barnum

Instead of being the newsgroup cop, maybe you should use a little humility
and actually read the post. It's guys like you that scare newbies from
newsgroups. I'll bet you didn't know everything when you posted your last
question.

Luther
 
P

Peter Hansen

Luther said:
Instead of being the newsgroup cop, maybe you should use a little humility
and actually read the post. It's guys like you that scare newbies from
newsgroups. I'll bet you didn't know everything when you posted your last
question.

Hmmm... I thought it was guys like me that answer dozens of questions
every week from newbies and others, but maybe I mistook me for someone else.

I did read Jeff's message, though, twice (once before responding, once
before sending). The second time I read it, I noticed (again) that he was
apparently aware that Pexpect did not work under Windows, but note his words:
"I have heard of Pexpect but was told".... a very clear indication that
he didn't know the real and full story, and hadn't visited the site. I tried
to provide in a somewhat humorous way the hint that "Google is your friend",
and I don't think he took offense (nor was any intended). Note also that
my response actually provided additional information as well: the fact that
Pexpect *does* "work fine using cygwin" under Windows, which apparently
Jeff didn't know either.

Yes, I could probably use a little humility, but I don't think you're
attacking me on the right issue here since I did read the post quite
thoroughly.

And no, I "didn't know everything" when I last asked a question here(*),
but I would have visited Google for a while before I did.

I apologize if I scare you, but I don't apologize for making repeated
reminders from time to time that people should do the initial legwork
themselves before asking. Nor, for that matter, do I apologize for
playing "net cop" from time to time and asking people to post test
messages elsewhere, to avoid cross-posting, to remember to change the
subject line when they change the subject, etc. etc. One reason Usenet
has gotten hard to use at times is because of the huge influx of newbies
and a lack of courage on the part of the oldsters to try to educate them
more often on proper netiquette.

-Peter

(*) I don't remember the last time I asked a question, but I believe it
was several months ago. I asked another one sometime last year, and I
think I've asked two others before that. One the other hand, I've posted
roughly ... let's see what Google says ... about 3,190 messages here in
the last three years. And I happen to believe a few of those have actually
helped people... While I actually appreciate attempts to improve my own
behaviour when I'm out of line, I'm fairly certain that I wasn't this time.
 
C

Cameron Laird

.
.
.
I did read Jeff's message, though, twice (once before responding, once
before sending). The second time I read it, I noticed (again) that he was
apparently aware that Pexpect did not work under Windows, but note his words:
"I have heard of Pexpect but was told".... a very clear indication that
he didn't know the real and full story, and hadn't visited the site. I tried
to provide in a somewhat humorous way the hint that "Google is your friend",
and I don't think he took offense (nor was any intended). Note also that
my response actually provided additional information as well: the fact that
Pexpect *does* "work fine using cygwin" under Windows, which apparently
Jeff didn't know either. .
.
.
I apologize if I scare you, but I don't apologize for making repeated
reminders from time to time that people should do the initial legwork
themselves before asking. Nor, for that matter, do I apologize for
.
.
.
Let me say some of this in my own words: your response
offered real value to Mr. Barnum because it provided
substantive information on
1. cygwin!Pexpect (technical detail), but also
2. to what an extent Google is our friend
(technical skill, let's say).
Long term, the latter might be a greater benefit. I
know how much it means to me when someone helps me learn
how to use resources better.
 
F

Fredrik Lundh

Cameron said:
Long term, the latter might be a greater benefit. I know how
much it means to me when someone helps me learn how to use
resources better.

who has time to learn? wasn't the internet supposed to
eliminate all that?

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top