title: Using R to download SAS file from ftp-server
body: <p>I am attempting to download some files onto my local from an ftp-server. I have had success using the following method to move .txt and .csv files from the server but not the .sas7bdat files that I need.</p>
  
  <pre><code>protocol &lt;- "sftp"
  server &lt;- "ServerName"
  userpwd &lt;- "User:Pass"
  tsfrFilename &lt;- "/filepath/file.sas7bdat" 
  ouptFilename &lt;- "out.sas7bdat"
  
  # Run #
  ## Download Data
  url &lt;- paste0(protocol, "://", server, tsfrFilename)
  data &lt;- getURL(url = url, userpwd=userpwd)
  
  ## Create File
  fconn &lt;- file(ouptFilename)
  writeLines(data, fconn)
  close(fconn)
  </code></pre>
  
  <p>When I run the getURL command, however, I am met with the following error:</p>
  
  <pre><code>Error in curlPerform(curl = curl, .opts = opts, .encoding = .encoding) : 
    embedded nul in string:
  </code></pre>
  
  <p>Does anyone know of any alternative way which I can download a sas7bdat file from an ftp-server to my local, or if there is a way to alter my code below to successfully download the file. Thanks!</p>