title: R Import - CSV file from password protected URL - in .BAT file
body: <p>Okay - so here is what I'm trying to do. </p>
  
  <p>I've got this password protected CSV file I'm trying to import into R. </p>
  
  <p>I can import it fine using: </p>
  
  <blockquote>
    <p>read.csv()</p>
  </blockquote>
  
  <p>and when I run my code in RStudio everything works perfect. </p>
  
  <p>However, when I try and run my .R file using a batch file (windows .bat) it doesn't work. I want to use the .BAT file so that I can set up a scheduled task to run my code every morning. </p>
  
  <p>Here is my .BAT file: </p>
  
  <blockquote>
    <p>"E:\R-3.0.2\bin\x64\R.exe" CMD BATCH "E:\Control Files\download_data.R" "E:\Control Files\DailyEmail.txt"</p>
  </blockquote>
  
  <p>And here is my .R file: </p>
  
  <blockquote>
    <p>url &lt;- "<a href="http://username:password@www.url.csv" rel="nofollow">http://username:password@www.url.csv</a>"</p>
    
    <p>data &lt;- read.csv(url, skip=1)</p>
  </blockquote>
  
  <p>** note, I've put my username/password and the exact location of the CSV in my code. I've used generic stuff here, as this is work related and posting usernames and passwords is probably frowned upon.  </p>
  
  <p>As I've said, this code works fine when I use it in RStudio. But fails when I use the .BAT file. </p>
  
  <p>I get the following error message: </p>
  
  <blockquote>
    <p>Error in download.file(url, "E:/data/data.csv") : 
      cannot open URL '<strong>websiteurl</strong>'
    In addition: Warning message:
    In download.file(url, "E:/data/data.csv") :
      <strong>unable to resolve 'username'</strong>
    Execution halted</p>
  </blockquote>
  
  <p>** above websiteurl is the http above (I can't post links)
  So obviously, the .BAT is having trouble with the username/password? Any thoughts?</p>
  
  <p><strong>* EDIT *</strong></p>
  
  <p>I've gone so far as trying this on Linux. Thinking maybe windows was playing silly bugger. </p>
  
  <p>Just from the terminal, I run Rscript -e "download_data.r" and get the EXACT same error message as I did in Windows. So I suspect this may be a problem with where I'm getting the data? Could the provider be blocking data from the command line, but not from with Rstudio? </p>