LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Blogs > Musings on technology, philosophy, and life in the corporate world
User Name
Password

Notices

Hi. I'm a Unix Administrator, mathematics enthusiast, and amateur philosopher. This is where I rant about that which upsets me, laugh about that which amuses me, and jabber about that which holds my interest most: Unix.
Rate this Entry

Update: remote Linux management via Python and ssh

Posted 12-30-2008 at 02:25 PM by rocket357
Updated 02-03-2009 at 09:16 PM by rocket357

I installed paramiko and tested out ssh.py (see the Edit on my last post). Python isn't just easy to use, it's *incredibly* easy to use...and now it's even more powerful and easy to use than before (is that possible?!?).

The problem with my last post is that you have to manually manage timing. It's a serious pain (Edit - relatively speaking, of course)...you "stdin.write("""<some long-running command>""")", and then you have to time.sleep() or manually check if <some long-running command> is still running. Blech...forget that.

Enter ssh.py. Here it is, in a nutshell:

Code:
import ssh

s = ssh.Connection("remotehost")
results = s.execute(<some long-running command>)
s.close()
for line in results: print line
Wow, that's simple...to the author of ssh.py: My hat's off to you.

Again, you'd want to add "production-quality" error handling, but that's the core of it. I'm currently updating my management scripts to use ssh.py heh

Edit - there is a continuation post here that continues where this post left off.
Posted in Uncategorized
Views 1478 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 12:54 AM.

Main Menu
Advertisement

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