[paramiko] scp not sftp

Rafael Ugolini rafael.ugolini at vexcorp.com
Tue May 22 07:08:26 PDT 2007


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

erick_bodine at comcast.net wrote:
> Supposedly scp is just rcp over an ssh connection.  Have you tried execing rcp instead of scp once you have the channel open?  Perhaps a look at the source of PuTTY (http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html), they have a pscp utility that might yield some clues.
>
> --
> --ERick
>
>  -------------- Original message ----------------------
> From: Rafael Ugolini <rafael.ugolini at vexcorp.com>
>   
>> Hi,
>>
>> I'm trying to use "scp" with paramiko to use with some old SSH version (v1).
>>
>> In SSHv1 scp work like this:
>> 1. you open a connection to the remote host
>> 2. create the channel
>> 3. exec scp -t filename
>> 4. send file info, eg. (C0664 SIZE 1\n)
>> 5. send data
>>
>> How do you guys think I can do this ?
>>
>> I did 2 methods and i failed with both.
>> ####### This one it stay on the first send
>>     def sendfile(self, path):
>>         chan = self._trans.open_session()
>>         chan.set_combine_stderr(True)
>>         f = file(path)
>>         print "send exec"
>>         chan.recv(1024)
>>         chan.send("execscp -v -t %s" % )
>>         chan.recv(1024)
>>         print "send mode and data"
>>         chan.send("C0664 %d 1\n" % os.stat(path)[6])
>>         chan.send("%s" % f.read())
>>         print "close"
>>         chan.close()
>>         f.close()
>>
>>
>> ####### Simple doesn't work
>>     def sendfile(self, path):
>>         chan = self._trans.open_session()
>>         chan.set_combine_stderr(True)
>>         f = file(path)
>>         print "send exec"
>>         chan.exec_command("scp -v -t %s" % )
>>         chan.recv(1024)
>>         print "send mode and data"
>>         chan.send("C0664 %d 1\n" % os.stat(path)[6])
>>         chan.send("%s" % f.read())
>>         print "close"
>>         chan.close()
>>         f.close()
>>
>> Thanks,
>>
>> Rafael Ugolini
>>
>> _______________________________________________
>> paramiko mailing list
>> paramiko at lag.net
>> http://mail.lag.net/mailman/listinfo/paramiko
>>     
>
>
> _______________________________________________
> paramiko mailing list
> paramiko at lag.net
> http://mail.lag.net/mailman/listinfo/paramiko
>   




More information about the paramiko mailing list