Skip to content

Instantly share code, notes, and snippets.

@AndreaCirilloAC
Last active August 10, 2016 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreaCirilloAC/d3fdd8c702dd055bc58a879fb1d91def to your computer and use it in GitHub Desktop.
Save AndreaCirilloAC/d3fdd8c702dd055bc58a879fb1d91def to your computer and use it in GitHub Desktop.
updateR(admin_password = "os_admin_user_password")
require(devtools)
install_github('andreacirilloac/updateR')
stopifnot(.Platform$OS.type == "unix")
page <- read_html(page_source)
version_block <- rvest::html_nodes(page,"h1+ p a+ a , table:nth-child(8) tr:nth-child(1) td > a")
filename <- rvest::html_text(version_block) %>% strsplit("\n", fixed = TRUE) # the resulting value is a list
filename <- filename[[2]] # we take the second element, containing the name of the file
filename_quoted <- paste("'",filename,"'",sep = "")
url <- paste(page_source,filename, sep = "")
download.file(url,filename)
command <- paste("echo " , admin_password, "| sudo -S installer -pkg ", filename_quoted , " -target / -verbose")
system(command)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment