Path: csiph.com!goblin2!goblin1!goblin.stu.neva.ru!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'cc:addr:python-list': 0.09; '===========': 0.09; 'str,': 0.09; 'subject:while': 0.09; 'sys.stdout': 0.09; 'typeerror:': 0.09; 'question.': 0.13; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'readable': 0.16; 'simplifies': 0.16; 'subject:issue': 0.16; 'subject:ssh': 0.16; 'wrote:': 0.16; 'bytes': 0.18; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'sep': 0.22; '(or': 0.23; 'header:In-Reply-To:1': 0.24; 'error': 0.27; 'message- id:@mail.gmail.com': 0.27; 'disk': 0.27; 'actual': 0.28; 'embed': 0.29; 'transaction': 0.30; 'code': 0.30; 'getting': 0.33; 'source': 0.33; 'tue,': 0.34; 'received:google.com': 0.35; 'best,': 0.35; 'follows:': 0.35; 'but': 0.36; 'child': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'missing': 0.37; 'means': 0.39; 'rather': 0.39; 'where': 0.40; 'some': 0.40; 'your': 0.60; 'more': 0.63; '=====': 0.84; '============': 0.84; 'chrisa': 0.84; 'password;': 0.84; 'subject:doing': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=51THYS5BfK0O4sK7CgBpxLz6czzys2Zpcyq27h4jMXM=; b=A8XnKlNYR2CKiFH7MYpOFdOdtY+g1UAHv7adG1sLJAfcZ7DmoLjoRVHBilKtaKCZSc yw8lhLyFgzrQ9CRMj0GZXHSAQNhu/vsI4ZDC9m5YxxK5BcssLv0P+lYQM6AzpvMhLID5 N44YgDkPTwcjIvguwo/B1AkPOny86nNSU/BUouRnAgU4pi763GGKsA9YBddlkrq5WNVJ NK77TamG9blYDz7hNqEwN6SiTZdfkUJhtqis2HKMrOpwLlC2Zp8GiIsEZkGV5uK798cJ /uxYPsDy/17Y56f5qt24zw8wbckdpmqGCARUKtX1dLI3D1TR+yFDxkHm+SPTUc0vENTc hAIQ== MIME-Version: 1.0 X-Received: by 10.50.98.7 with SMTP id ee7mr41501497igb.13.1441720661248; Tue, 08 Sep 2015 06:57:41 -0700 (PDT) In-Reply-To: <3f4642c2-d548-4089-87c2-f3abb4ccb224@googlegroups.com> References: <3f4642c2-d548-4089-87c2-f3abb4ccb224@googlegroups.com> Date: Tue, 8 Sep 2015 23:57:41 +1000 Subject: Re: issue while doing pexpect ssh From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1441720664 news.xs4all.nl 23730 [2001:888:2000:d::a6]:53295 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:96128 On Tue, Sep 8, 2015 at 9:37 PM, wrote: > Some where i am missing simple logic.... :) > > ===== > child = pexpect.spawn('ssh hari@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 rather than keying in a password; it's a lot more secure, as it means you don't have to embed a password in your source code (or at very best, on your hard disk in some other readable and decryptable way). It also simplifies the transaction significantly. ChrisA