[R] Closing FTP sessions with RCurl
Tom Wright
tom at maladmin.com
Tue Jun 14 22:00:51 CEST 2016
No expert here, and this isn't tested. It seems you can set the
forbid.reuse option which will cause curl to shutdown the connection
after transfer is complete.
if(url.exists("http://www.omegahat.net/RCurl/index.html")) {
curl <- getCurlHandle()
curlSetOpt(.opts=list(forbid.reuse=1),curl=curl)
getURL("http://www.omegahat.net/RCurl/index.html", curl = curl)
}
On Tue, Jun 14, 2016 at 2:41 PM, J Payne <jcpayne at uw.edu> wrote:
> Does anyone know how to close an FTP session with RCurl? I am trying to automate the process of downloading snow data from a government website, and their server is throttling the connection after a few files are downloaded. I contacted their system administrator, who wrote: “My suspicion at this point is that the getURL commands are opened and perform the function asked, then linger in wait for 15 minutes until or ftp server closes the idle sessions. Is there a way to tell R to close the sessions?”
>
>
>
> I’ve perused the RCurl manual but I don’t see a way to close sessions. I tried copying the following example from the RCurl manual, but it didn’t solve the problem. I’m a novice at this and I don’t understand the relationship between handles and sessions, so I am probably missing something.
>
>
>
> #EXAMPLE from getCurl(), p. 39
>
> if(url.exists("http://www.omegahat.net/RCurl/index.html")) {
>
> curl = getCurlHandle()
>
> getURL("http://www.omegahat.net/RCurl/index.html", curl = curl)
>
> #getCurlInfo(curl) # I skipped this step
>
> rm(curl) # release the curl! (does this end the session???)
>
> }
>
>
>
> Thanks!
>
>
>
> John
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list