Implementing SCP with paramiko

  • Post author:
  • Post category:Python

Regular readers will note that I've been interested in how scp works and paramiko for the last couple of days. There are previous examples of how to do scp with paramiko out there, but the code isn't all on one page, you have to read through the mail thread and work it out from there. I figured I might save someone some time (possibly me!) and note a complete example of scp with paramiko... #!/usr/bin/python # A simple scp example for Paramiko. # Args: # 1: hostname # 2: username # 3: local filename # 4: remote filename import getpass import os import paramiko import socket import sys # Socket connection to remote host sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((sys.argv[1], 22)) # Build a SSH transport t = paramiko.Transport(sock) t.start_client() t.auth_password(sys.argv[2], getpass.getpass('Password: ')) # Start a scp channel scp_channel = t.open_session() f = file(sys.argv[3], 'rb') scp_channel.exec_command('scp -v -t %s\n' % '/'.join(sys.argv[4].split('/')[:-1])) scp_channel.send('C%s %d %s\n' %(oct(os.stat(sys.argv[3]).st_mode)[-4:], os.stat(sys.argv[3])[6], sys.argv[4].split('/')[-1])) scp_channel.sendall(f.read()) # Cleanup f.close() scp_channel.close() t.close() sock.close()

Continue ReadingImplementing SCP with paramiko

Robot Visions

  • Post author:
  • Post category:Book

This was a pretty short read -- in fact I read it on the bus into work this morning. That's mainly because there are only three short stories in this book which aren't covered in one of Asimov's other robot short story collections. The three stories were good, but I am not sure they were worth owning the entire book for. [isbn: 0451450647]

Continue ReadingRobot Visions

The Belgariad

  • Post author:
  • Post category:Book

The Belgariad is a fantasy series by David Eddings. There are five books in the series, although there is also a follow series called the Mallorean, as well as three tie in books. The series follows a small farm boy as he grows up, discovering along the way that his relatives are famous, he's important to the history of the world, and that he has to defeat an ancient evil. The five books in the main series are: 1982: Pawn of Prophecy 1982: Queen of Sorcery 1983: Magician's Gambit 1984: Castle of Wizardry 1984: Enchanters' End Game

Continue ReadingThe Belgariad

Enchanters End Game

  • Post author:
  • Post category:Book

This is the final book in the Belgariad. Its a good one, although knowing there is another series involving these characters makes it feel a little less final to me. I enjoyed it though. [isbn: 0345338715]

Continue ReadingEnchanters End Game

MythNetTV release 5

  • Post author:
  • Post category:Mythtv

New things in this release: There is now a users mailing list at http://lists.stillhq.com/listinfo.cgi/mythnettv-stillhq.com Moved to a public SVN server at http://www.stillhq.com/mythtv/mythnettv/svn/ Added the 'justone' syntax to the download command Another try at using gflags. This means that all the command lines have changed slightly. Moved the core of MythTV out of the user interface file. Started writing unit tests Changed user output code so that it doesn't insist on writing to stdout. You can now write to other file descriptors, which makes things like unit tests much easier to write. Added video/msvideo to the enclosure whitelist Added HTTP download progress information Added a flag which turns off the prompts for markread (--noprompt) Patches from Thomas Mashos Search ~/.mythtv/mysql.txt, /usr/share/mythtv/mysql.txt and /etc/mythtv/mysql.txt in that order for MySQL connection information A manpage setup.py video.py now has a simple command line interface to let you query it Fix update of inactive programs bug per http://ubuntuforums.org/showpost.php?p=5580005&postcount=4 Better DB error handling Included a COPYING file with the right version of the GPL (it was missing before) Fixed a bug where programs would be downloaded more than once (found with a unit test!) Started raising exceptions instead of just sys.exit(1). This should make life easier…

Continue ReadingMythNetTV release 5

Castle Of Wizardry

  • Post author:
  • Post category:Book

This is book four in the Belgariad, and was as good as the others. This one only took a day to read, but that was helped a lot by the two hours I spent commuting to and from San Francisco today. This book is a little different than the others because it starts just as the quest for the Orb ends. Yet it turns out that the overall prophecy that the Belgariad describes is still incomplete, so the story continues. [isbn: 0345300807]

Continue ReadingCastle Of Wizardry

Magician’s Gambit

  • Post author:
  • Post category:Book

This is the third book in the Belgariad (Book 1 and Book 2). This book like the others was an enjoyable quick and easy read. I am starting to rethink my comments about these books being good for young readers -- it just occurred to me that a lot of people die in these books. They're all bad guys, and the violence isn't all that graphic, but I guess it might worry some parents. [isbn: 0345335457]

Continue ReadingMagician’s Gambit

Queen of Sorcery

  • Post author:
  • Post category:Book

This is book two of the Belgariad (following on from Pawn of Prophecy). This book was a good quick read, and I think they'd be a good mid level reading book for a child. I liked it. [isbn: 0345335651]

Continue ReadingQueen of Sorcery

First Family

  • Post author:
  • Post category:Book

I finished this book on the bus into work this morning (I had a pretty distracted weekend, and didn't get much reading done). This is the second book in the Amtrak Wars series, and takes place immediately after Cloud Warrior. The book feels like it is only half a book -- there is plot development such as learning more about Roz, meeting the First Family, and the Iron Masters, but there isn't much action. Basically I look back on the book and wonder what happened in it -- it would have been better to combine this with the next book and have a complete story in one. [isbn: 0671655671;0722185170]

Continue ReadingFirst Family

End of content

No more pages to load