[Tutor] sftp get single file
Matt Herzog
msh at blisses.org
Tue Jul 21 00:18:19 CEST 2009
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.
>
> 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?
> Also have a look at [2] which is a good example of what can be done.
Yeah I saw that page. The code seemed bloated to me.
>
> Greets
> Sander
>
> [1] http://www.lag.net/paramiko/docs/paramiko.SFTPClient-class.html
> [2] http://code.activestate.com/recipes/576810/
> _______________________________________________
> 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