You can embed the username and password in the url like :
http://userid:passw@domain.name:port/...
This you can try to use with readLines()
. If that doesn't work, you can always try a workaround using url()
to open the connection :
zz <- url("http://userid:passw@domain.name:port/...")
readLines(zz)
close(zz)
You can also download the file and save it somewhere using download.file()
download.file("theurl","/path/to/file/filename",method="wget")
This saves the file on the local path that is specified.
EDIT :
as csgillespie said, you shouldn't include your username and password in the script. If you run scripts with source() or interactively, you could add eg :
user <- readline("Give the username : ")
passw <- readline("Give the password : ")
Url <- paste("http://",user,":",passw,"@domain.name...")
readLines(Url,...)
When running from the commandline, you could pass the arguments after --args and access them using commandArgs
(see ?commandArgs
)