RCurl使用选项ftpupload = TRUE转储核心

时间:2018-09-11 15:16:49

标签: r curl rcurl

我尝试将一个小文件ftp上载到ftp服务器上,该服务器我必须与“ active” ftp(curl -P选项)一起使用,我的R会话转储核心。知道这里发生了什么,我必须将哪些选项传递给RCurl::ftpUpload()

.opts <- list("verbose" = TRUE, "ftp.use.epsv" = FALSE, 
    "ftp.use.eprt" = TRUE, "connecttimeout" = 3, ftpport=TRUE)
myfile <- "path/myfile.json"
file.exists(myfile)   # returns  TRUE

cmd <- sprintf("ftp://%s:%s@myserver.de/mytargetdir/%s", 
   Sys.getenv("R__ftpuser"), Sys.getenv("R__ftppw"), 
   basename(myfile))
ftpUpload(myfile, cmd, .opts=.opts)

*捕获了段错误* 地址0x1,导致“内存未映射”

Traceback:
 1: curlPerform(url = to, upload = TRUE, readfunction = uploadFunctionHandler(file,     asText), ..., curl = curl)
 2: ftpUpload(myfile, cmd, .opts = .opts)

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace

我的R会话:

R version 3.4.4 (2018-03-15)  for linux
RCurl version 1.95-4.11

命令行调用有效:

curl -P - myfile ftp://... -T --disable-eprt #uploads the file

我的卷发:

curl 7.47.0 (x86_64-pc-linux-gnu) libcurl/7.47.0 GnuTLS/3.4.10 zlib/1.2.8 libidn/1.32 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP UnixSockets

当我忽略ftpport=TRUE选项时,会超时。

R --vanilla

也会发生这种情况

1 个答案:

答案 0 :(得分:0)

回答我自己的问题:

选项值必须为"-",而不是TRUE

.opts <- list("verbose" = TRUE, "ftp.use.epsv" = FALSE, "ftpport" = "-",
              "ftp.use.eprt" = TRUE, "connecttimeout" = 3)
ftpUpload(myfile, cmd, .opts=.opts)

然后输出将如下所示:

< 150 Opening BINARY mode data connection for myfile.json
* Preparing for accepting server on data port
* Checking for server connect
* Ready to accept data connection from server
* Connection accepted from server
* Remembering we are in dir "some/dir/"
< 226 Transfer complete
* Connection #0 to host myserver.de left intact

此行为记录在https://curl.haxx.se/libcurl/c/CURLOPT_FTPPORT.html

  

PORT指令告诉远程服务器连接到我们的   指定的IP地址。该字符串可以是纯IP地址,也可以是主机   名称,网络接口名称(在Unix下)或只是一个“-”符号   让图书馆使用您系统的默认IP地址。

(重点是我的)