issue while doing pexpect ssh

Laura Creighton lac at openend.se
Wed Sep 9 06:45:56 EDT 2015


In a message of Wed, 09 Sep 2015 01:58:30 -0700, harirammanohar159 at gmail.com wr
ites:

>Thank you for spawnu, now i got stuck with freezing issue similar to it is not returing to the shell prompt...its on waiting...i had to press ctrl+c
>
>===========
>child.sendline(password)
>child.expect('-bash-4.1$')
>child.sendline('ls')
>print(child.before)
>child.sendline('su - user1')
>child.expect('-bash-4.1$')
>child.sendline('pwd; hostname')
>print(child.before)
>child.close()

>WARNING. You have accessed a private computer system.
<lots more threats and stuff>

Any doubts we had about whether the computer policy authorities
as this place are 'nuttier than 2 trees full of squirrels' are
now put to rest.  I just hope I am not helping you do things that
is going to end up with them trying to put you in jail.  Poor you.

>su - user1
>
>lsTotal users logged in under your name (via BoKS): 3 (2 on this host)
>Total users logged in (via BoKS): 8324 (2 on this host)
>-bash-4.1$ ls
>-bash-4.1$ su - user1
>-bash-4.1$

Okay.
Instead of waiting for that bash-4.1 prompt
after you issue your su, issue whoami
and wait to see if it returns user1.

That way we can see if the problem is with expect waiting for the prompt
which for some reason it is not seeing, or whether it is just lost, lost,
lost.

Also, for informational purposes try your su without the '-'
just "su user1", and see if it is some part of the 'provide an environment
similar to what the user would get if the user logged in directly'
ability of su that is confusing things.

Laura





More information about the Python-list mailing list