Learn R Programming

pbdRPC (version 0.2-1)

ssh_plink: ssh and plink

Description

Commend line tools including ssh for Linux, Mac OSX, Solaris, or plink for Windows.

Usage

ssh(args = "snoweye@192.168.56.101 whoami", intern = .pbd_env$RPC.CT$intern,
  wait = .pbd_env$RPC.CT$wait)

plink(args = "snoweye@192.168.56.101 whoami", use.shell.exec = .pbd_env$RPC.CT$use.shell.exec, pause = .pbd_env$RPC.CT$pause, intern = .pbd_env$RPC.CT$intern, wait = .pbd_env$RPC.CT$wait)

check_exec(exec)

run_args(exec = "ssh", args = "", use.shell.exec = .pbd_env$RPC.CT$use.shell.exec, pause = .pbd_env$RPC.CT$pause, intern = .pbd_env$RPC.CT$intern, wait = .pbd_env$RPC.CT$wait)

Arguments

args

All in text/characters that are passed to the command line.

intern, wait

arguments passed to system() or shell() whereever they are applicable.

use.shell.exec

if shell.exec() is used to execute the plink command in windows. No returns can be captured by R when this is TRUE as the default, because the authentication may not be generally available in most windows system. No easy yet secure way to by passing the password from R to external calls in shell.

pause

if pause when shell.exec is used in Windows.

exec

either ssh (i.e. /usr/bin/ssh) or a ``full path'' to plink.

Value

Mainly the message received at the command line will be returned.

Details

These functions only execute option/command on remote servers via secure client commands.

NO further input from stdin is expected. Outputs or errors may not be captured by R.

ssh() starts a ssh command.

plink() starts a plink command used by default for Windows.

check_exec() runs a quick check on the exec (either ssh or plink) for rpc.

run_args() runs a rpc via either ssh or plink.

Examples

Run this code
# NOT RUN {
library(pbdRPC, quietly = TRUE)
rpcopt_set(user = "snoweye", hostname = "192.168.56.101")

### Check an R session.
cmd <- "Rscript -e 'sessionInfo()'"

### For Linux, Mac OSX, Solaris.
rpc(cmd = cmd, exec.type = "ssh")

### For Windows.
rpc(cmd = cmd, exec.type = "plink")

### Manually
args <- "snoweye@192.168.56.101 Rscript -e 'sessionInfo()'"
ssh(args)      # Note ssh uses "-p" for server port.
plink(args)    # Note plink uses "-P" for server port.

### Manually launch a remoter server at background.
user.hostname <- "snoweye@192.168.56.101"
preload <- "source ./work-my/00_devel_R"
rr <- "nohup Rscript -e 'remoter::server()' > .rrlog 2>&1 < /dev/null &"
args <- paste(user.hostname, " \"", preload, "; ", rr, "\"", sep = "")
plink(args)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab