Go Job Hunting at the LQ Job Marketplace
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 03-15-2011, 12:53 PM   #1
Registered: Oct 2010
Posts: 167

Rep: Reputation: 0
Pexpect output !

Hi all.

Today i have download pexpect and started working on it. I want to access my cisco router and capture the output of "show version". So far i am successful in configuring the router. Pls check the script below

import pexpect
import sys

child=pexpect.spawn("ssh cisco@")

child.sendline("conf ter")

child.sendline("int loo 200")
child.logfile = sys.stdout

Now on my router, the configuration was done perfectly. Which means my pexpect script is working fine. But i am not able to get the following

1) I want to capture the output of 'show version' (or any other command) to a file. When i googled, the last bolded line seemed to be the solution but its not working. When i run the script, it simply runs and then i get the prompt again, no output of show version :-(

Pls someone guide me
Old 03-16-2011, 11:31 PM   #2
Senior Member
Registered: Nov 2005
Distribution: Debian
Posts: 2,815

Rep: Reputation: 999Reputation: 999Reputation: 999Reputation: 999Reputation: 999Reputation: 999Reputation: 999Reputation: 999
I've never used pexpect, but I would guess that you need to set the logfile before running the commands.


pexpect, python

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Getting xdebug 2.0.5 switch text output to html output lhorace Linux - Server 1 11-01-2009 06:23 PM
LXer: HowTo Manage your networked devices using Python and Pexpect LXer Syndicated Linux News 0 09-28-2009 03:40 PM
ps -eH | grep java output in a active passive clustered output johnkalikavunkal Linux - Server 2 01-31-2009 12:21 AM
python: pexpect problems? Chowroc Programming 0 03-03-2006 12:08 AM
the sound gives output when using mic but no output when run a music file medo Debian 0 04-19-2004 08:17 PM

All times are GMT -5. The time now is 07:59 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration