cannot get pexpect to work

Discussion in 'Python' started by Andrei, Aug 29, 2003.

  1. Andrei

    Andrei Guest

    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.
    Andrei, Aug 29, 2003
    #1
    1. Advertising

  2. Andrei

    Andrei Guest

    "Peter Hansen" <> wrote in message
    news:...
    > 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.
    Andrei, Aug 29, 2003
    #2
    1. Advertising

  3. Andrei

    Andrei Guest

    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.
    Andrei, Aug 29, 2003
    #3
  4. Andrei

    Peter Hansen Guest

    Andrei wrote:
    >
    > "Peter Hansen" <> wrote in message
    > news:...
    > > 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
    Peter Hansen, Aug 29, 2003
    #4
  5. Andrei

    Andrei Guest

    > 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
    Andrei, Aug 29, 2003
    #5
  6. Andrei

    Andrei Guest

    "Peter Hansen" <> wrote in message
    news:...

    > 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.
    Andrei, Aug 30, 2003
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jurian Sluiman

    Get pexpect to work

    Jurian Sluiman, Oct 29, 2006, in forum: Python
    Replies:
    2
    Views:
    575
  2. BlackjadeLin
    Replies:
    2
    Views:
    1,146
    BlackjadeLin
    Jan 13, 2008
  3. Karim Bernardet

    get the pid of a process with pexpect

    Karim Bernardet, May 5, 2008, in forum: Python
    Replies:
    2
    Views:
    554
    Karim Bernardet
    May 6, 2008
  4. Linuxguy123
    Replies:
    1
    Views:
    850
    Gary Duzan
    Jan 30, 2009
  5. Saqib Ali
    Replies:
    1
    Views:
    358
    Roy Smith
    Dec 26, 2011
Loading...

Share This Page