[Tutor] sftp get single file

Wayne srilyk at gmail.com
Tue Jul 21 00:26:09 CEST 2009


On Mon, Jul 20, 2009 at 5:18 PM, Matt Herzog <msh at blisses.org> wrote:

> On Mon, Jul 20, 2009 at 11:57:57PM +0200, Sander Sweers wrote:
> > Please reply to the list.
> >
> > 2009/7/20 Matt Herzog <msh at blisses.org>:
> > > Yeah. I have no idea if I am able to do this. The jail makes it
> ambiguous.
> >
> > There is no difference, the jail just moves the root directory as seen
> > by the client.
> >
> > Did you do as suggested earlier to use listdir()? This will tell you
> > how paramiko sees the server.
>
> Yeah, I managed to get that to work like so:
>
> if __name__ == "__main__":
>    t = paramiko.Transport((hostname, port))
>    t.connect(username=username, password=password)
>    sftp = paramiko.SFTPClient.from_transport(t)
>     print sftp.listdir()
>    t.close()
>
> It displays the contents of the dir no problem.


Is the file present in the dir? What is it listed as? Is it just
07232009.tab (or similar) or is it /home/user/jail/07232009.tab? That may
make a difference.


>
>
> >
> > I get the feeling you are in on over your head on this.
>
> Yes, and I have a deadline.
>
> > Maybe you need
> > to read the paramiko docs and play around in idle or other interactive
> > python interpreter. The SFTPClient has all the basic commands any ssh
> > client has (listdir, chdir etc). See [1].
>
> I should not need to chdir, right? In fact, the server's policy forbids it.
> Perhaps I need to chdir on the local host?


That shouldn't make a difference as far as getting the file is concerned -
unless you're trying to put it in a file on your computer that doesn't
exist!

I'd really recommend playing around in the interpreter - especially if you
have ipython.

Good luck, HTH,
Wayne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090720/1035348a/attachment.htm>


More information about the Tutor mailing list