Search code examples
rsftprcurl

sftp with R - sftp not a protocol with RCurl


I've read a few posts on sftp with R, but was not able to address the problem that I have. There's a decent change I'm just not searching in the right place, and if that's the case, please point me in the right direction. Here's where I'm at:

> library(RCurl)
> curlVersion()
$age
[1] 3

$version
[1] "7.43.0"

$vesion_num
[1] 469760

$host
[1] "x86_64-apple-darwin15.0"

$features
     ipv6       ssl      libz      ntlm asynchdns    spnego largefile   ntlm_wb 
        1         4         8        16       128       256       512     32768 

$ssl_version
[1] "SecureTransport"

$ssl_version_num
[1] 0

$libz_version
[1] "1.2.5"

$protocols
 [1] "dict"   "file"   "ftp"    "ftps"   "gopher" "http"   "https"  "imap"   "imaps"  "ldap"   "ldaps"  "pop3"   "pop3s"  "rtsp"   "smb"    "smbs"   "smtp"   "smtps"  "telnet" "tftp"  

$ares
[1] ""

$ares_num
[1] 0

$libidn
[1] ""

Right away, I notice that sftp is not a protocol accepted in my current version of RCurl, which is my main problem. As a result, when I run the following code below, I get the following error:

# Input 
protocol <- "sftp"
server <- "00.000.00.00"
userpwd <- "userid:userpass"
tsfrFilename <- 'myfile.txt'
ouptFilename <- 'myfile.txt'

# Run
url <- paste0(protocol, "://", server, tsfrFilename)
data <- getURL(url = url, userpwd = userpwd)

Error in function (type, msg, asError = TRUE)  : 
  Protocol "sftp" not supported or disabled in libcurl

I actually have a second question as well. My understanding is that getURL grabs data from the other server and pulls it to my local machine, whereas I would like to put a file onto the server from my local machine.

To summarize: (1) can I update RCurl / libcurl in R to support sftp, and (2) how do i put files from my local machine into the server, rather than get files from the server to my local machine?

Thanks!


Solution

  • I found the answer, for the most part...

    http://andrewberls.com/blog/post/adding-sftp-support-to-curl - following this link addressed the problem for me.

    I've successfully added sftp support to cURL, however I am now struggling to update the RCurl package to have the same...