[Tutor] paramiko again
Matt Herzog
msh at blisses.org
Sun May 10 02:32:19 CEST 2009
On Sun, May 10, 2009 at 12:53:49AM +0100, Alan Gauld wrote:
> Have you used normal ftp in its command line version?
> The put command specifies the location on the remote machine
> where you want to store the files. This is normal ftp behaviour.
The server supports only sftp. Yeah, I could turn on ftp on some server but that would be more work. Heh.
> Yes. sftp is an object that you create with a call from paramiko.
> The class exists in paramiko and you create an instance of it
> called sftp.
Oh. I could call it anything, not that I'd want to. Thanks. I kept thinking I could find it using ipython.
> So you are trying to upload files that currently exist on the
> remote machine from your machine, that is unlikely to work.
Yes. That was not the plan though. Heh.
> I suspect you probably need to change the listdir() call to use
> os.listdir(local_path) instead of stftp.listdir(). Where local_path
> is wherever you store the files on the local mnachine that you
> want to transfer.
Yes, that is exactly what I wanted, os.listdir. But now I have another issue:
specifying the remote dir. When I login to the sftp server and type pwd:
sftp> pwd
Remote working directory: /
Is what I see.
Also, I don't think I want "join" in the below, do I? Why do I want to "join" the two dirs? As far as I'm concerned, I just want to dump files into the only dir I can reach, which is "/" on the remote host's jail.
sftp.get(os.path.join(dir_path, f), f)
>
> HTH,
It did help. Many thanks!
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
--
I fear you speak upon the rack,
Where men enforced do speak anything.
- William Shakespeare
More information about the Tutor
mailing list