[paramiko] scp not sftp
Rafael Ugolini
rafael.ugolini at vexcorp.com
Wed May 23 10:55:09 PDT 2007
James Bardin wrote:
> 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?
hmm, i don't remember why i put it there, but i was reading some docs and
they were using something like
scp -v -t .
C0664 "size" "filename"
but, the way i'm doing works.
>
>
> 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