Path: csiph.com!news.swapon.de!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!feeder.erje.net!1.eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!nzpost1.xs4all.net!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'string.': 0.04; 'cc:addr :python-list': 0.09; 'received:openend.se': 0.09; 'received:theraft.openend.se': 0.09; 'str,': 0.09; 'subject:while': 0.09; 'sys.stdout': 0.09; 'cc:addr:lac': 0.16; 'cc:addr:openend.se': 0.16; 'from:addr:lac': 0.16; 'from:addr:openend.se': 0.16; 'from:name:laura creighton': 0.16; 'message-id:@fido.openend.se': 0.16; 'received:fido': 0.16; 'received:fido.openend.se': 0.16; 'skip:> 20': 0.16; 'subject:issue': 0.16; 'subject:ssh': 0.16; 'bytes': 0.18; 'laura': 0.18; '2015': 0.20; 'cc:addr:python.org': 0.20; 'cc:2**1': 0.22; 'sep': 0.22; 'error': 0.27; '-0700,': 0.29; 'received:se': 0.29; 'cc:no real name:2**1': 0.29; 'url:mailman': 0.30; 'url:python': 0.33; 'url:listinfo': 0.34; 'tue,': 0.34; 'follows:': 0.35; 'skip:> 10': 0.35; 'unicode': 0.35; 'url:org': 0.36; 'subject:: ': 0.37; 'missing': 0.37; 'charset:us-ascii': 0.37; 'url:en': 0.39; 'url:mail': 0.40; 'where': 0.40; 'header :Message-Id:1': 0.61; 'email addr:gmail.com': 0.62; 'header:In- reply-to:1': 0.84; 'subject:doing': 0.84; 'url:api': 0.84; 'url:readthedocs': 0.84; 'url:latest': 0.91 To: harirammanohar159@gmail.com cc: python-list@python.org, lac@openend.se From: Laura Creighton Subject: Re: issue while doing pexpect ssh In-reply-to: <3f4642c2-d548-4089-87c2-f3abb4ccb224@googlegroups.com> References: <3f4642c2-d548-4089-87c2-f3abb4ccb224@googlegroups.com> Comments: In-reply-to harirammanohar159@gmail.com message dated "Tue, 08 Sep 2015 04:37:09 -0700." MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <30927.1441714347.1@fido> Content-Transfer-Encoding: quoted-printable Date: Tue, 08 Sep 2015 14:12:27 +0200 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (theraft.openend.se [82.96.5.2]); Tue, 08 Sep 2015 14:12:30 +0200 (CEST) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1441714357 news.xs4all.nl 23791 [2001:888:2000:d::a6]:58835 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 3691 X-Received-Body-CRC: 131814475 Xref: csiph.com comp.lang.python:96125 In a message of Tue, 08 Sep 2015 04:37:09 -0700, harirammanohar159@gmail.c= om wr ites: >Some where i am missing simple logic.... :) > >=3D=3D=3D=3D=3D >child =3D pexpect.spawn('ssh hari@hostname') >child.logfile =3D sys.stdout >child.expect('hari\'s Password: ') >=3D=3D=3D=3D=3D > >getting error as follows: >=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >child.expect('hari\'s Password: ') >TypeError: must be str, not bytes >=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > >Thanks... >-- = >https://mail.python.org/mailman/listinfo/python-list https://pexpect.readthedocs.org/en/latest/api/pexpect.html#run-function you want to use spawnu because you have a unicode string. Laura