Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76286

Re: pexpect - logging input AND output

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.061
X-Spam-Evidence '*H*': 0.88; '*S*': 0.00; 'output': 0.05; 'socket': 0.07; 'that).': 0.09; 'cc:addr:python-list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'input': 0.22; 'aug': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'easier': 0.31; 'figure': 0.32; 'open': 0.33; 'running': 0.33; "can't": 0.35; 'connection': 0.35; 'but': 0.35; 'received:google.com': 0.35; '14,': 0.36; 'possible': 0.36; 'pm,': 0.38; 'expect': 0.39; 'how': 0.40; 'read': 0.60; 'commands': 0.60; 'simply': 0.61; "you'll": 0.62; 'initiates': 0.84; 'to:none': 0.92; 'device.': 0.93; 'subject:AND': 0.93
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=cm/n/ILdTtjlJox+ZiD7mLjVBrlEkNRgd0+Vbyg2gY4=; b=AH5mD9BM5kP0V0MVBbZEm5cFndciLyZGA0X+4Y0OxIty28hEMCJuHcJzMduuXrrYYb KrQaUu2tTxyz8rin/VKTyMRyGQv0ax4l1r8ZBTSOmyNs58JsLT/8ig23vofPPAffZDa0 H5hpImttJ9vpCg9SJESndGrQgu5bdA42bYkRJwwBwH1wE7d++y00Sg5c9UzSZ270fnHw U0zR+k4uXf+FULypWxXJrFeoEmv5oCn9F7FY1YRr+Fb81qXQwEV9u6fSbJvAG0dHJ58T 0uWuC95J8f0b0SeK2YyY77jAhkV1ieSti0XsaoS3vqnqQdbAbo1WF8tjVYxlQFnT72xF kwFA==
MIME-Version 1.0
X-Received by 10.50.66.197 with SMTP id h5mr57076878igt.34.1408007691318; Thu, 14 Aug 2014 02:14:51 -0700 (PDT)
In-Reply-To <f6f7175a-37cc-44d0-9e62-b237f51d6ac8@googlegroups.com>
References <f6f7175a-37cc-44d0-9e62-b237f51d6ac8@googlegroups.com>
Date Thu, 14 Aug 2014 19:14:51 +1000
Subject Re: pexpect - logging input AND output
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12986.1408007694.18130.python-list@python.org> (permalink)
Lines 12
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1408007694 news.xs4all.nl 2876 [2001:888:2000:d::a6]:60224
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:76286

Show key headers only | View raw


On Thu, Aug 14, 2014 at 6:59 PM,  <sj.constantine@gmail.com> wrote:
> i have a script running a few commands on a network device. i can't seem to figure out how to log both the input and output of what the pexpect script initiates and responds to.
>
> child = pexpect.spawn ('telnet '+ ip)

If that's not working for you, would it be easier instead to simply
open a socket connection to port 23 on that IP address? Then you'd
just write to the socket (and log what you write) and read from it
(and log that). It's possible you'll see some TELNET or ANSI codes
coming back, but I expect you won't have to send any of them.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

pexpect - logging input AND output sj.constantine@gmail.com - 2014-08-14 01:59 -0700
  Re: pexpect - logging input AND output Chris Angelico <rosuav@gmail.com> - 2014-08-14 19:14 +1000
  Re: pexpect - logging input AND output Akira Li <4kir4.1i@gmail.com> - 2014-08-20 18:51 +0400

csiph-web