LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Blogs > rocket357
User Name
Password

Notices

Rate this Entry

Update: remote Linux management via Python and ssh

Submit "Update: remote Linux management via Python and ssh" to Digg Submit "Update: remote Linux management via Python and ssh" to del.icio.us Submit "Update: remote Linux management via Python and ssh" to StumbleUpon Submit "Update: remote Linux management via Python and ssh" to Google Submit "Update: remote Linux management via Python and ssh" to LinuxQuestions.org
Posted 12-30-2008 at 03:25 PM by rocket357
Updated 02-03-2009 at 10: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 893 Comments 0 Edit Tags
« Prev     Main     Next »
Total Comments 0

Comments

 


All times are GMT -5. The time now is 06:03 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration