Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > cannot get pexpect to work

Reply
Thread Tools

cannot get pexpect to work

 
 
Andrei
Guest
Posts: n/a
 
      08-29-2003
Hi,

I'm at a crucial stage in the development of a wide area (multi-host) ssh
wrapper, and need to control what happens when a host requires password
authentication. After installing pexpect, the example script that looks most
inclined to help me (by basically handling this situation,) "passmass.py"
seems to fail, from whatever host to whatever host eg.

[user1@baddog01 scripts]$ ./passmass.py localhost
Username: user1
Current Password:
New Password:
Confirm New Password:
'Timeout exceeded in read().' <<< ?

Does anyone have a clue what's going on?

Many thanks

Andrei.


 
Reply With Quote
 
 
 
 
Andrei
Guest
Posts: n/a
 
      08-29-2003
"Peter Hansen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> No, but why is it asking for a new password confirmation?
> You're just trying to log in, not change the password, aren't
> you? Or does passmass.py actually change the passwords, not
> just log in? (I don't have the script.) Have you read it?
> Perhaps you've misinterpreted what it is supposed to do.


that's exactly right, as I forgot to mention: it changes passwds
on a list of remote systems, this list being the list of args to
the script, which is now linked here btw:

http://area52.homeunix.org/testarea/passmass.py.txt

cheers

A.





 
Reply With Quote
 
 
 
 
Andrei
Guest
Posts: n/a
 
      08-29-2003
the following is completely wrong of course in my own hacked version of the
script linked in the previous msg:

# SHELL_PROMPT = '[#\$] '
SHELL_PROMPT = '[$?] ${PWD#${PWD%/*/*/*}/}> '

but even when the login shell prompt on remote machine must end in # or $ as
the script insists, and you leave

SHELL_PROMPT = '[#\$] '

the "timed out" message persists, hence my puzzlement ...

A.


 
Reply With Quote
 
Peter Hansen
Guest
Posts: n/a
 
      08-29-2003
Andrei wrote:
>
> "Peter Hansen" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > No, but why is it asking for a new password confirmation?
> > You're just trying to log in, not change the password, aren't
> > you? Or does passmass.py actually change the passwords, not
> > just log in? (I don't have the script.) Have you read it?
> > Perhaps you've misinterpreted what it is supposed to do.

>
> that's exactly right, as I forgot to mention: it changes passwds
> on a list of remote systems, this list being the list of args to
> the script, which is now linked here btw:
>
> http://area52.homeunix.org/testarea/passmass.py.txt


Unfortunately at this moment (13:45 EDT) I get no response to
connection requests on port 80. (That is, server is answering
pings, but no web server on standard port.)

-Peter
 
Reply With Quote
 
Andrei
Guest
Posts: n/a
 
      08-29-2003
> Unfortunately at this moment (13:45 EDT) I get no response to
> connection requests on port 80. (That is, server is answering
> pings, but no web server on standard port.)


sorry, I had to bring the homeserver down because of a bad thunderstorm ...
after which someone else must have taken the ip address=)

here it is on another server which is altogether more impervious to
meteorogical changes ...

http://tufish.org/misc/passmass.py.txt


 
Reply With Quote
 
Andrei
Guest
Posts: n/a
 
      08-30-2003
"Peter Hansen" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> Best solution: this is Python (!), so just start up an interactive
> session and type the relevant commands yourself, based on what you
> see in pexpect.py. Not only will you solve the problem, but you'll
> end up with a much better understanding of pexpect.py and the passmass.py
> script as well.


An interactive session certainly did the trick.

>>> child = pexpect.spawn('ssh lxplus003 uptime')
>>> try:

.... child.expect('password:')
.... print "problem encountered, password needed"
.... except Exception:
.... print "ok no passwd required"
....
0
problem encountered, password needed


I still haven't figured out why passmass.py isn't finishing and indeed times
out yet, but a basic understanding of pexpect is now creeping up on me, and
how it could help my project.

Thanks,

A.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing the system clock with pexpect confuses pexpect! Saqib Ali Python 1 12-26-2011 01:51 PM
Why doesn't this work in Eclipse ? (Simple pexpect code thatworks in bash) Linuxguy123 Python 1 01-30-2009 05:21 PM
get the pid of a process with pexpect Karim Bernardet Python 2 05-06-2008 12:43 PM
Why my program (using pexpect to switch user) doesn't work well? BlackjadeLin Python 2 01-13-2008 03:15 AM
Get pexpect to work Jurian Sluiman Python 2 10-29-2006 09:26 PM



Advertisments