Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back > Blogs > Musings on technology, philosophy, and life in the corporate world
User Name


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 (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) "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 Here it is, in a nutshell:

import ssh

s = ssh.Connection("remotehost")
results = s.execute(<some long-running command>)
for line in results: print line
Wow, that's the author of 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 heh

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




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