This code will help quickly transfer data from a remote server, instead of using SFTP/FTP client, like WinSCP.
# 1. Load "RCurl" package library ("RCurl") # Input # protocol <- "sftp" server <- "12.345.6.789" userpwd <- "user:pwd" tsfrFilename <- "/test/example.csv" #you can transfer other kinds, like text, as well. ouptFilename <- "~/output/example.csv" # Run # ## Download Data url <- paste0(protocol, "://", server, tsfrFilename) data <- getURL(url = url, userpwd=userpwd) ## Create File fconn <- file(ouptFilename) writeLines(data, fconn) close(fconn)
Hi thanks your code works fine with .txt file. But while connecting to linux server and retrieving SAS dataset. I am hitting with below error.
Error in curlPerform(curl = curl, .opts = opts, .encoding = .encoding) :
embedded nul in string: ‘Âê`³2421Ͻ’\b\tÇ1Œ303720213″3301021010301303720213″330102101301#3( 0301SAS FILEPATCH_WORKLOAD DATA AÕ¥%ÖüÙAAÕ¥%ÖüÙA ¬@ ¬@ I9.0301M1Linux2.6.18-348.el5x86_64AÕ¥%\r›Ê@\r›Ê@\r›Ê@R/|àAÕ¥%ÖüÙA