[paramiko] scp not sftp
James Bardin
jbardin at bu.edu
Tue May 22 09:06:31 PDT 2007
That's great! I tried this a while back and never got it working.
I also noticed that putty's scp looks like it first tries to use sftp
for the transfer.
FYI, you can format the mode like:
mode = os.stat(path).st_mode
'C%s' % oct(mode)[-4:]
If you import the stat module you can also:
mode = os.stat(path).st_mode
'C%s' % oct(stat.S_IMODE(mode))
Do you know what the 1 is for in the file info line?
Thanks
-jim
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()
>
> Thanks,
>
> Rafael Ugolini
>
>
More information about the paramiko
mailing list