Skip to content

Commit

Permalink
add silly single quotes and it works in Windows (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkEdmondson1234 committed Mar 2, 2017
1 parent 9577fd6 commit f23d75c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
12 changes: 5 additions & 7 deletions R/ssh.R
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,9 @@ do_system <- function(instance,
## do the command
myMessage(cmd, " ", paste(sargs, collapse = " "), level = 2)

if(.Platform$OS.type != "windows"){
status <- system2(cmd, args = sargs, wait = wait, stdout = capture, stderr = capture)
} else {
status <- shell(paste(cmd, sargs), wait = wait)
}

status <- system2(cmd, args = sargs, wait = wait, stdout = capture, stderr = capture)



if(capture == TRUE){
Expand All @@ -218,7 +216,7 @@ do_system <- function(instance,
if(!is.null(attr(status, "status"))){
myMessage("Remote error: ", attr(status, "status"), attr(status, "errmsg"), level = 3)
}

## status is the output text
## parse out the connection warning
host_warn <- status[grepl("^Warning: Permanently added .* to the list of known hosts.\r$", status)]
Expand All @@ -229,7 +227,7 @@ do_system <- function(instance,
} else {
## status if error code (0 for success)
if (status == 127) {
stop("ssh failed\n", cmd, sargs, call. = FALSE)
stop("ssh failed\n", cmd, paste(sargs, collapse = " "), call. = FALSE)
}

## output may be written to file if capture = "filepath"
Expand Down
4 changes: 2 additions & 2 deletions R/ssh_admin.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ssh_options <- function(instance) {
opts <- c(
BatchMode = "yes",
StrictHostKeyChecking = "no",
UserKnownHostsFile = file.path(tempdir(), "hosts")
UserKnownHostsFile = paste0("'",file.path(tempdir(), "hosts"),"'")
)

if(exists("ssh", instance)){
Expand All @@ -15,7 +15,7 @@ ssh_options <- function(instance) {

c(paste0("-o ", names(opts), "=", opts, collapse = " "),
" -i ",
private_key)
paste0("'",private_key,"'"))
}

#' Add SSH details to a gce_instance
Expand Down

0 comments on commit f23d75c

Please sign in to comment.