2012-02-06 2 views
2

I 간단한 업로드 스크립트와 단지 사로 잡았 다음 일을 작성 :컬 (pycurl) FTP

단순화 된 코드 :

import pycurl 
from os.path import getsize 

c = pycurl.Curl() 
c.setopt(pycurl.URL, 'ftp://<ftp_name>:21/asus.c') 
c.setopt(pycurl.USERPWD, 'username:password') 
c.setopt(pycurl.PROXY, '10.0.0.35') 
c.setopt(pycurl.PROXYPORT, 3128) 
c.setopt(pycurl.VERBOSE, 1) 
f = open('asus.c') 
c.setopt(pycurl.INFILE, f) 
c.setopt(pycurl.INFILESIZE, getsize('asus.c')) 
c.setopt(pycurl.HTTPPROXYTUNNEL, 1) 
c.setopt(pycurl.UPLOAD, 1) 
c.perform() 
시도가 FTP 서버에 PUT을 할 말림

거의 동일한 코드가 아니라 몇 달 전에 작동했지만 :

* About to connect() to proxy <IP> port 3128 (#0) 
* Trying <IP>... * connected 
* Connected to <IP> (<IP>) port 3128 (#0) 
* Establish HTTP proxy tunnel to <ftp_name>:21 
* Server auth using Basic with user 'username' 
> CONNECT <ftp_name>:21 HTTP/1.1 
Host: <ftp_name>:21 
User-Agent: PycURL/7.21.6 
Proxy-Connection: Keep-Alive 

< HTTP/1.0 200 Connection established 
< 
* Proxy replied OK to CONNECT request 
* Server auth using Basic with user 'username' 
> PUT /asus.c HTTP/1.1 
Authorization: Basic _______________________________ 
User-Agent: PycURL/7.21.6 
Host: <ftp_name>:21 
Accept: */* 
Content-Length: 2627 
Expect: 100-continue 

220 ProFTPD 1.3.3 Server (______ FTP Server) [<IP>] 
500 PUT not understood 
500 AUTHORIZATION: not understood 
500 USER-AGENT: not understood 
500 HOST: not understood 
500 ACCEPT: not understood 
500 CONTENT-LENGTH: not understood 
500 EXPECT: not understood 
500 Invalid command: try being more creative 

와 동일한 응답 나는이 작업을 수행 할 때 쉘에서 :

curl --upload-file "asus.c" --proxy 10.0.0.35:3128 \ 
--proxytunnel -u username:password ftp://<ftp_name>/asus.c 

왜? 나는 무엇을 놓쳤는가?

+0

당신이 FTP 서버에 HTTP를 이야기하려고하는 것 같습니다 자세한. 프록시가 이러한 설정을 사용하여 FTP 프록시로 작동합니까 (예 : 브라우저 또는 알려진 FTP 클라이언트에서? – 9000

+0

예. FileZilla는이 프록시 (구성된 오징어)를 통해 잘 연결 (업로드)합니다. –

답변

0

FTP 업로드에 대한 구문은 다음과 같습니다

curl -u "[email protected] Proxy-Username:Remote-Pass"  --ftp-account Proxy-Password --upload-file local-file  ftp://my-ftp.proxy.server:21/remote/upload/path/ 
+1

목표는 http-proxy를 통해 업로드하는 것이 었습니다. –

2

여기 나를 위해 작동하는 형식입니다.

curl --user 'ftp_user:ftp_password' --disable-epsv --proxytunnel -x 'yourproxy.com:port' -T 'your.localfile' 'ftp://remote.ftp.org:port/path' -v 

나는 그 매개 변수와 함께 투쟁하면 FTP 문제로 컬이 있으면 알려 주시기 위해 많은 시간을 보냈다. 당신이 필요로하는 경우

-U or --proxy-user <proxy_user:proxy_password> 프록시 사용이 인증을

--proxy-basic 경우 소화 경우 원격 FTP 사용자 이름과 암호

--proxy-digest이있는 경우 프록시 자격 증명

-u or --user <ftp_user:ftp_password> : 여기

관련 일부 매개 변수입니다 프록시에서 기본 인증을 사용합니다.

--proxy-anyauth 프록시 인증을 원할 경우

-l or --list-only FTP 디렉토리 만 나열하려면이 옵션을 선택하십시오.

기본 인증을 사용하여 인증을

--basic 원격 FTP를 소화 사용 --digest 원격 FTP

-3 or --sslv3 (SSL) 부대는 -x or --proxy이있는 경우 원격 SSL 서버

-p or --proxytunnel와 연결할 때 SSL 버전 3을 사용하는 컬 이 옵션을 사용하면 비 HTTP 프로토콜이 http와 비슷한 작업을 수행하는 대신 프록시를 통해 터널링을 시도합니다.

-v or --verbose 당신이 필요로하는 경우

--ftp-ssl