[Tutor] sftp get single file
msh at blisses.org
Tue Jul 21 04:16:49 CEST 2009
On Mon, Jul 20, 2009 at 05:26:09PM -0500, Wayne wrote:
> 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.
Yes, the file 20090720.tab (today's date dot tab) is present in the dir listing. The dir contents are printed out in a comma delimited list from left to right that wraps several times. There are probably 30 subdirs and a dozen files in that dir. If you use the sftp cli binary and type, 'pwd' it tells you, '/'.
> > >
> > > 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 .
> > 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
I'm trying to put a file in a dir called /tmp/testor. The user the script runs as owns the dir.
> I'd really recommend playing around in the interpreter - especially if you
> have ipython.
I have ipython. I like ipython. I just don't get enough opportunities to do python scripting.
> Good luck, HTH,
I fear you speak upon the rack,
Where men enforced do speak anything.
- William Shakespeare
More information about the Tutor