Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82125 > unrolled thread
| Started by | pengsir <elearn2014@gmail.com> |
|---|---|
| First post | 2014-12-09 00:14 -0800 |
| Last post | 2014-12-08 22:25 +0000 |
| Articles | 4 — 4 participants |
Back to article view | Back to comp.lang.python
why can't download file from linux server into local window disk c:? pengsir <elearn2014@gmail.com> - 2014-12-09 00:14 -0800
Re: why can't download file from linux server into local window disk c:? Luuk <luuk@invalid.lan> - 2014-12-08 17:37 +0100
Re: why can't download file from linux server into local window disk c:? Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2014-12-08 20:36 +0100
Re: why can't download file from linux server into local window disk c:? Nobody <nobody@nowhere.invalid> - 2014-12-08 22:25 +0000
| From | pengsir <elearn2014@gmail.com> |
|---|---|
| Date | 2014-12-09 00:14 -0800 |
| Subject | why can't download file from linux server into local window disk c:? |
| Message-ID | <mailman.16725.1418055279.18130.python-list@python.org> |
My vps ip is x.y.z.w ,i want to download /etc/passwd from linux server
into my local window disk c: .
import paramiko
host = "x.y.z.w"
port = 22
transport = paramiko.Transport((host, port))
password = "mykey"
username = "root"
transport.connect(username = username, password = password)
sftp = paramiko.SFTPClient.from_transport(transport)
filepath = '/etc/passwd'
localpath = 'c:'
sftp.get(filepath, localpath)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Python34\lib\site-packages\paramiko\sftp_client.py", line
719, in get
with open(localpath, 'wb') as fl:
PermissionError: [Errno 13] Permission denied: 'c:'
[toc] | [next] | [standalone]
| From | Luuk <luuk@invalid.lan> |
|---|---|
| Date | 2014-12-08 17:37 +0100 |
| Message-ID | <5485d3c8$0$2832$e4fe514c@news.xs4all.nl> |
| In reply to | #82125 |
On 9-12-2014 09:14, pengsir wrote: > > > My vps ip is x.y.z.w ,i want to download /etc/passwd from linux server > into my local window disk c: . > > import paramiko > host = "x.y.z.w" > port = 22 > transport = paramiko.Transport((host, port)) > password = "mykey" > username = "root" > transport.connect(username = username, password = password) > sftp = paramiko.SFTPClient.from_transport(transport) > filepath = '/etc/passwd' > localpath = 'c:' > sftp.get(filepath, localpath) > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > File "D:\Python34\lib\site-packages\paramiko\sftp_client.py", line > 719, in get > > with open(localpath, 'wb') as fl: > PermissionError: [Errno 13] Permission denied: 'c:' You, 'root', does not have enoug permission to do it.... C:\temp>\util\Putty\pscp root@opensuse:/etc/passwd . Using keyboard-interactive authentication. Password: Access denied
[toc] | [prev] | [next] | [standalone]
| From | Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> |
|---|---|
| Date | 2014-12-08 20:36 +0100 |
| Message-ID | <m64uk8$ua2$1@r01.glglgl.de> |
| In reply to | #82125 |
Am 09.12.2014 09:14 schrieb pengsir: > My vps ip is x.y.z.w ,i want to download /etc/passwd from linux server > into my local window disk c: . > localpath = 'c:' [...] > with open(localpath, 'wb') as fl: > PermissionError: [Errno 13] Permission denied: 'c:' That's completely clear: you are not allowed to create a file named 'c:'. You should replace it with a full path name, such as localpath = 'c:\\passwd' or such. Thomas
[toc] | [prev] | [next] | [standalone]
| From | Nobody <nobody@nowhere.invalid> |
|---|---|
| Date | 2014-12-08 22:25 +0000 |
| Message-ID | <pan.2014.12.08.22.25.03.434000@nowhere.invalid> |
| In reply to | #82125 |
On Tue, 09 Dec 2014 00:14:15 -0800, pengsir wrote: > localpath = 'c:' > sftp.get(filepath, localpath) > with open(localpath, 'wb') as fl: > PermissionError: [Errno 13] Permission denied: 'c:' It's trying to open "c:", which is a drive, as if it was a file. You have to specify the destination filename, not just the directory. Also, you probably shouldn't be trying to write to the root directory of the C drive. You should probably be using a directory beneath either %USERPROFILE% or %ALLUSERSPROFILE%. Writing to the root of the system drive tends to require Administrator privileges. Even if the current user is an administrator, the process must have elevated privilege (e.g. via "Run as Administrator" or an explicit privilege-elevation request from within the code).
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web