issue while doing pexpect ssh

jmp jeanmichel at sequans.com
Tue Sep 8 10:56:50 EDT 2015


On 09/08/2015 03:57 PM, Chris Angelico wrote:
> On Tue, Sep 8, 2015 at 9:37 PM,  <harirammanohar159 at gmail.com> wrote:
>> Some where i am missing simple logic.... :)
>>
>> =====
>> child = pexpect.spawn('ssh hari at hostname')
>> child.logfile = sys.stdout
>> child.expect('hari\'s Password: ')
>> =====
>>
>> getting error as follows:
>> ============
>> child.expect('hari\'s Password: ')
>> TypeError: must be str, not bytes
>> ===========
>
> Laura's already answered your actual question. But I would recommend
> using public key login [snip]
>
> ChrisA
>

My 2 cents, beside the public key, use the python module paramiko, 
unless you really want to work at the low level yourself.

http://docs.paramiko.org/en/1.15/api/client.html

JM




More information about the Python-list mailing list