Download your favorite Linux distribution at LQ ISO.
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-01-2012, 11:32 PM   #1
Registered: Jul 2005
Posts: 144

Rep: Reputation: 15
Paramiko and Python 2.6

Hi, I am using paramiko to try and ssh2 into my linux box and run some cli commands(NOT a linux shell). Is this possible, because the following code segment is not working:

in, out, err = sshObj.exec_command(cmdStr)
for line in out.readlines():
  print line
I am able to connect to the remote host, but the above code prints out the very first line after logging into the Cli instead of the result of the command.

Thanks in advance.
Old 03-03-2012, 08:45 AM   #2
Senior Member
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
What is cmdStr set to, and how are you initialising sshObj? Essentially, can you give us a complete piece of code that runs properly, the output you get when running it, and the output you expect?

EDIT: Wait, are you trying to run a 'sudo' command? In which case the 'Password:' prompt is not the last line of the login, but a request for the sudo password. Just add:
then the command output should be written to 'out'.

Last edited by Snark1994; 03-03-2012 at 08:52 AM.


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
Python 2.6 dependencies error installing python-sqlite2-2.5.5-1.1.i586.rpm jmp007 Linux - Newbie 1 02-11-2011 12:05 PM
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 09:30 PM
LXer: Review: Programming in Python 3: A Complete Introduction to the Python Language LXer Syndicated Linux News 0 01-26-2009 05:50 AM
python update - Unable to load GTK2 Python bindings: No module named gtk itpedersen Linux - Software 2 10-03-2008 04:44 AM
LXer: Move to python 2.4 / Changing the packaging style for python packages LXer Syndicated Linux News 0 06-13-2006 08:54 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:26 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