[paramiko] scp not sftp

Robey Pointer robey at lag.net
Wed May 23 10:07:53 PDT 2007


On 22 May 2007, at 7:08, Rafael Ugolini wrote:

> It didn't help me too much, but i got it working now.
>
>     def sendfile(self, path):
>         chan = self._trans.open_session()
>         f = file(path, "rb")
>         chan.exec_command("scp -v -t %s\n" % path.split("/")[-1])
>         chan.send("C0664 %d 1\n" % os.stat(path)[6])
>         chan.sendall("%s" % ( f.read()))
>         f.close()
>         chan.close()

Very cool.  I didn't know that was how scp worked.

By the way, you should be able to change this line:

     chan.sendall("%s" % ( f.read()))

to this:

     chan.sendall(f.read())

robey




More information about the paramiko mailing list