Package pbdrpc. February 2, 2018

Similar documents
A Quick Guide for the pbdrpc Package

Package remoter. August 29, 2016

Package ssh. June 4, 2018

Package datasets.load

Package rcmdcheck. R topics documented: November 10, 2018

Version Using remoter with Remote Machines. Taking R to the Cloud and Beyond. Drew Schmidt

Package callr. August 29, 2016

Package knitrprogressbar

Package svkomodo. R topics documented: February 20, Type Package Version Date

Version Guide to the remoter Package. Just the Basics. Drew Schmidt

Package messaging. May 27, 2018

Package pbdzmq. May 5, 2018

Package calpassapi. August 25, 2018

Package googlecomputeenginer

Package gtrendsr. August 4, 2018

Package mdftracks. February 6, 2017

Package redux. May 31, 2018

Package argon2. June 12, 2017

A Quick Guide for the pbdzmq Package

Package dbx. July 5, 2018

Package spark. July 21, 2017

Package Rserve. R topics documented: February 19, Version Title Binary R server

Package fastdummies. January 8, 2018

Package repec. August 31, 2018

Package clipr. June 23, 2018

Package ECctmc. May 1, 2018

Package validara. October 19, 2017

Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package strat. November 23, 2016

Package future. October 17, 2017

Package R.rsp. January 11, 2018

Package getopt. February 16, 2018

Package aws.transcribe

Package shinyhelper. June 21, 2018

Package rbraries. April 18, 2018

Package taxizedb. June 21, 2017

Remote Access Via Remote Desktop

Package sessioninfo. June 21, 2017

Package robotstxt. November 12, 2017

Package pmclust. February 2, 2018

Package deductive. June 2, 2017

Package SEMrushR. November 3, 2018

Package benchmarkme. R topics documented: February 26, Type Package Title Crowd Sourced System Benchmarks Version 0.2.

Package regexselect. R topics documented: September 22, Version Date Title Regular Expressions in 'shiny' Select Lists

Package spelling. December 18, 2017

Package ecoseries. R topics documented: September 27, 2017

Package assertive.reflection

Package available. November 17, 2017

Package geogrid. August 19, 2018

Package RcppParallel

Package oec. R topics documented: May 11, Type Package

Package goodpractice

Package pkgbuild. October 16, 2018

Package gtrendsr. October 19, 2017

Package sylcount. April 7, 2017

Package fitbitscraper

Package dotcall64. January 11, 2018

Package kirby21.base

Package rmatio. July 28, 2017

Package jstree. October 24, 2017

Package tiler. June 9, 2018

Package SASmarkdown. R topics documented: November 30, Version Date Title 'SAS' Markdown

Package lumberjack. R topics documented: July 20, 2018

Supercomputing environment TMA4280 Introduction to Supercomputing

Package BiocManager. November 13, 2018

Package RODBCext. July 31, 2017

Package gridgraphics

Package librarian. R topics documented:

Package reval. May 26, 2015

Package pwrab. R topics documented: June 6, Type Package Title Power Analysis for AB Testing Version 0.1.0

Package httpcache. October 17, 2017

Package liftr. R topics documented: May 14, Type Package

Package triebeard. August 29, 2016

Package cronr. March 3, 2017

Package ggimage. R topics documented: November 1, Title Use Image in 'ggplot2' Version 0.0.7

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package GetoptLong. June 10, 2018

Shell Scripting. With Applications to HPC. Edmund Sumbar Copyright 2007 University of Alberta. All rights reserved

Package githubinstall

Package catchr. R topics documented: December 30, Type Package. Title Catch, Collect, and Raise Conditions. Version 0.1.0

Package doredis. R topics documented: February 19, Type Package

Package geneslope. October 26, 2016

Package wikitaxa. December 21, 2017

Package patentsview. July 12, 2017

Package readmzxmldata

Package bigqueryr. October 23, 2017

Package callr. January 30, 2018

Package pbmcapply. August 16, 2017

Package reportr. October 6, 2016

Package RPushbullet. February 17, 2017

Package pinyin. October 17, 2018

Package ggimage. R topics documented: December 5, Title Use Image in 'ggplot2' Version 0.1.0

Package internetarchive

Bitnami Apache Solr for Huawei Enterprise Cloud

Package projector. February 27, 2018

Package rprojroot. January 3, Title Finding Files in Project Subdirectories Version 1.3-2

Package rtsdata. October 26, 2018

Package crochet. January 8, 2018

Package autoshiny. June 25, 2018

Package ezknitr. September 16, 2016

Transcription:

Package pbdrpc February 2, 2018 Version 0.2-0 Date 2018-02-01 Title Programming with Big Data -- Remote Procedure Call Depends R (>= 3.2.0), tools Enhances pbdzmq, remoter, pbdmpi LazyLoad yes LazyData yes Copyright See pbdrpc/inst/putty_licence for files in src/putty/. A very light implementation yet secure for remote procedure calls with unified interface via ssh (OpenSSH) or plink/plink.exe (PuTTY). SystemRequirements ssh (OpenSSH) or plink (PuTTY) on Solaris, Linux, and Mac. License Mozilla Public License 2.0 URL http://r-pbd.org/ BugReports http://group.r-pbd.org/ MailingList Please send questions and comments regarding pbdr to RBigData@gmail.com RoxygenNote 6.0.1 NeedsCompilation yes Maintainer Wei-Chen Chen <wccsnow@gmail.com> Author Wei-Chen Chen [aut, cre], Drew Schmidt [aut] Repository CRAN Date/Publication 2018-02-02 04:31:59 UTC 1

2 find_plink R topics documented: pbdrpc-package...................................... 2 find_plink.......................................... 2 Initial Control Functions.................................. 3 machine........................................... 4 print-machine........................................ 5 rpc.............................................. 5 RPC Control Environment................................. 6 RPC Control Functions................................... 7 rpc_cs_example....................................... 8 rpc_options......................................... 9 rpc_pid........................................... 10 rpc_rr_example....................................... 11 srpc............................................. 13 ssh_plink.......................................... 14 tunnel............................................ 16 Index 17 pbdrpc-package pbdrpc A very light yet secure implementation of remote procedure call. Author(s) Wei-Chen Chen and Drew Schmidt References Project URL: https://github.com/rbigdata/pbdrpc find_plink Find plink Find the plink internal compiled with pbdrpc package. find_plink()

Initial Control Functions 3 The function returns a full path to the plink or plink.exe command if found. A full path a full path to the plink or plink.exe command if found. Otherwise, "plink" is returned. Examples ## Not run: library(pbdrpc, quietly = TRUE) find_plink() ## End(Not run) Initial Control Functions Initial controls in pbdrpc Initial control functions.rpcopt_init(envir =.GlobalEnv) envir an environment where RPC controls locate.rpcopt_init() initials default RPC controls..rpcopt_init() initial the RPC control at envir. Author(s) Wei-Chen Chen <wccsnow@gmail.com>. References ZeroMQ/4.1.0 API Reference: http://api.zeromq.org/4-1:_start Programming with Big Data in R Website: http://r-pbd.org/

4 machine See Also.pbd_env. Examples ## Not run: library(pbdrpc, quietly = TRUE) rpcopt_set(user = "snoweye", hostname = "192.168.56.101") ls(.pbd_env) rm(.pbd_env).rpcopt_init() ls(.pbd_env).pbd_env$rpc.li ## End(Not run) machine machine Remote machine configuration settings. machine(hostname, user, exec.type =.pbd_env$rpc.li$exec.type, args =.pbd_env$rpc.li$args, pport =.pbd_env$rpc.li$pport, priv.key =.pbd_env$rpc.li$priv.key, priv.key.ppk =.pbd_env$rpc.li$priv.key.ppk) hostname user exec.type args the server ip or host name. user id for logging to the server. If none is supplied, then the system user name will be used instead. either "ssh" or "plink" in character. Windows will force to use "plink". further arguments to "ssh" or "plink" for connecting to the server in addition to port, user id, and host name. pport ssh port opened on the server. priv.key, priv.key.ppk location of the private key for user authentication, the file will be checked first then -i priv.key will be added to args when the file exists. priv.key.ppk is only used when plink is called.

print-machine 5 An object of class machine. Examples ## Not run: # note: not my actual aws url myaws <- machine("ec2-1-2-3-4.compute-1.amazonaws.com", user="my_aws_username") # if you don't specify 'user', we use your host machine's user name myvm <- machine("192.168.1.10") ## End(Not run) print-machine print-machine Printing for machine class objects. ## S3 method for class 'machine' print(x,...) x machine class object... ignored rpc Remote Procedure Call Launch a command via ssh or plink on a (remote) server. rpc(machine, cmd = "whoami", intern =.pbd_env$rpc.ct$intern, wait =.pbd_env$rpc.ct$wait)

6 RPC Control Environment machine cmd intern, wait A machine configuration. See?machine. the command to be executed on the server. arguments passed to system() or shell() whereever they are applicable. Using either ssh or plink to launch a command on a (remote) server. Authentication is working currently for ssh. NO further input from stdin is expected. Outputs or errors may not be captured by R. Mainly the message received from the command line of server may be returned but may not be captured by R. For example, Windows with plink will not capture the return because currently the authentication is not working. A windows bat file is launched by shell.exec() in an additional cmd.exe window to avoid saving password inside R. See Also machine(), start_rr(), check_rr(), kill_rr(), srpc(), ssh(), and plink(). RPC Control Environment Sets of controls in pbdrpc. These sets of controls are used to provide default values in this package. Format Objects contain several parameters for communicators and methods. The elements of.pbd_env$rpc.ct are default values for looking RPC control files. The elements of.pbd_env$rpc.li are default values for RPC defult login information. Author(s) Wei-Chen Chen <wccsnow@gmail.com>. Programming with Big Data in R Website: http://r-pbd.org/

RPC Control Functions 7 See Also.rpcopt_init(). RPC Control Functions Sets of controls in pbdrpc. These sets of controls are used to provide default values in pbdrpc package. RPC.CT(verbose = FALSE, intern = FALSE, wait = TRUE, check.exec = FALSE, use.shell.exec = TRUE, pause = TRUE) RPC.LI(exec.type = "ssh", args = "", pport = 22, user = "snoweye", hostname = "192.168.56.101", priv.key = "~/.ssh/id_rsa", priv.key.ppk = "./id_rsa.ppk") RPC.RR(check = "ps axww grep '[r]emoter::server'", kill = "kill -9 $(ps axww grep '[r]emoter::server' awk '{print $1}')", start = "nohup Rscript -e 'remoter::server()' >.rrlog 2>&1 < /dev/null &", preload = "source ~/work-my/00_set_devel_r; ", checkx = "ps axww grep '[r]emoter::server\\ [x]vfb-run'", killx = "kill -9 $(ps axww grep '[r]emoter::server\\ [x]vfb-run' awk '{print $1}')", startx = "nohup xvfb-run Rscript -e 'remoter::server()' >.rrlog 2>&1 < /dev/null &") verbose, intern, wait, check.exec, use.shell.exec, pause RPC control for system, shell.exec, and so on. wait = FALSE allows asynchronous commands which need more test. e.g. continuously port forwarding without sending commands to background. exec.type, args, pport, user, hostname, priv.key, priv.key.ppk RPC login information used by srpc(), ssh(), or plink(). check, kill, start, preload, checkx, killx, startx RPC remoter commands used by check_rr(), kill_rr(), or start_rr() and virtual X11 related versions checkx_rr(), killx_rr(), or startx_rr().. RPC pbdcs commands used by check_cs(), kill_cs(), or start_cs(). Author(s) See Also Wei-Chen Chen <wccsnow@gmail.com>. Programming with Big Data in R Website: http://r-pbd.org/.pbd_env.

8 rpc_cs_example rpc_cs_example Example Functions of RPC Related to pbdcs Example functions of RPC related to pbdcs check_cs(machine, cmd =.pbd_env$rpc.cs$check) kill_cs(machine, cmd =.pbd_env$rpc.cs$kill) start_cs(machine, cmd =.pbd_env$rpc.cs$start, preload =.pbd_env$rpc.cs$preload) machine cmd preload A machine configuration. See?machine. the main command to be executed on the server. further commands preloaded before the main command is executed. Using either ssh or plink to launch a pbdcs R cluster. NO further input from stdin is expected. Outputs or errors may not be captured by R. start_cs() starts a pbdcs R cluster on remote servers. Typical commands to launch a pbdcs R cluster is given in the example. The linux/unix commands are as the following: 1)nohup is for the non-stop call after disconnection. 2)mpiexec -np 4 is for launching 4 MPI instances. 3)Rscript -e 'pbdcs::pbdserver()' is for R to start the pbdcs R cluster within MPI in batch. 4)>.rrlog is to direct the stdout to a file.rrlog 5)2>&1 is to turn stderr to stdout which is the file.cslog. 6)< /dev/null is to get stdin from /dev/null which is nothing happen. 7)& is to put the batch command for the pbdcs R cluster in background. check_cs() checks if there is a pbdcs R cluster on a remote server. Lunix/unix commands ps and grep are used. kill_cs() kills the pbdcs R cluster if found. Lunix/unix commands ps, grep, awk, and kill are used.

rpc_options 9 Mainly the message received at the command line will be printed, but may not be captured by R. Examples ## Not run: library(pbdrpc, quietly = TRUE) # rpcopt_set(user = "snoweye", hostname = "192.168.56.101") m <- machine(user = "snoweye", hostname = "192.168.56.101") check_cs(m) kill_cs(m) check_cs(m) # pid 2857 (may differ) # all pbdcs pids are killed # make sure no pbdcs R cluster is running ### use "; " to bypass multiple commands preload <- "source ~/work-my/00_set_devel_r; " ### start a new pbdcs R cluster start_cs(m, preload = preload) check_cs(m) kill_cs(m) ### Example: for module load on supercomputers preload <- "module load r; " # e.g. via module load r start_cs(m, preload = preload) check_cs(m) kill_cs(m) ## End(Not run) rpc_options Set and Get Options for Remote Procedure Call Set and get default options of login information for srpc(). rpcopt_set(user = NULL, hostname = NULL, pport = NULL, exec.type = NULL, args = NULL, priv.key = NULL, priv.key.ppk = NULL) rpcopt_get()

10 rpc_pid user hostname pport exec.type args priv.key priv.key.ppk user id for logging to the server. the server ip or host name. ssh port opened on the server. either "ssh" or "plink". arguments to the ssh or plink.exe. file name/path to the private key in OpenSSH format. file name/path to the private key in PuTTY format. rpcopt_set() is to alter default options of login information. The user defined options are set to.pbd_env$rpc.li. rpcopt_get() is to get default options of login information from.pbd_env$rpc.li. A list is returned. See Also rpc(), srpc(). Examples ## Not run: library(pbdrpc, quietly = TRUE) rpcopt_set(user = "snoweye", hostname = "192.168.56.101") rpcopt_get() ## End(Not run) rpc_pid Search or kill possible pid s of Remote Procedure Call Search or kill possible pid s that running remote procedure calls in background. rpc_ps() rpc_kill(pid)

rpc_rr_example 11 pid a vector containing proccess id s in interger. rpc_ps() prints possible pid s that running remote procedure calls in background via one of ssh, plink, plink.exe, or cmd.exe. rpc_kill() kill pid s. List or kill all possible pid s. rpc_rr_example Example Functions of RPC Related to Remote R Server Example functions of RPC related to remote R server check_rr(machine, cmd =.pbd_env$rpc.rr$check) checkx_rr(machine, cmd =.pbd_env$rpc.rr$checkx) kill_rr(machine, cmd =.pbd_env$rpc.rr$kill) killx_rr(machine, cmd =.pbd_env$rpc.rr$killx) start_rr(machine, cmd =.pbd_env$rpc.rr$start, preload =.pbd_env$rpc.rr$preload) startx_rr(machine, cmd =.pbd_env$rpc.rr$startx, preload =.pbd_env$rpc.rr$preload) machine cmd preload A machine configuration. See?machine. the main command to be executed on the server. further commands preloaded before the main command is executed.

12 rpc_rr_example Using either ssh or plink to launch a remote R server. NO further input from stdin is expected. Outputs or errors may not be captured by R. start_rr() starts a remote R server on a remote server. Typical commands to launch a remoter R server is given in the example. The linux/unix commands are as the following: 1)nohup is for the non-stop call after disconnection. 2)Rscript -e 'remoter::server()' is for R to start the remote R server in batch. 3)>.rrlog is to direct the stdout to a file.rrlog 4)2>&1 is to turn stderr to stdout which is the file.rrlog. 5)< /dev/null is to get stdin from /dev/null which is nothing happen. 6)& is to put the batch command for the remoter R server in background. check_rr() checks if there is a remote R server on a remote server. Lunix/unix commands ps and grep are used. kill_rr() kills remote R servers if found. Lunix/unix commands ps, grep, awk, and kill are used. checkx_rr(), killx_rr(), and startx_rr() are functions with virtual X11 windows. Mainly the message received at the command line will be printed, but may not be captured by R. Examples ## Not run: library(pbdrpc, quietly = TRUE) # rpcopt_set(user = "snoweye", hostname = "192.168.56.101") m <- machine(user = "snoweye", hostname = "192.168.56.101") check_rr(m) kill_rr(m) check_rr(m) # pid 2857 (may differ) # all remoter pids are killed # make sure no remoter servers are running ### use "; " to bypass multiple commands preload <- "source ~/work-my/00_set_devel_r; " ### start a new remoter server start_rr(m, preload = preload) check_rr(m) kill_rr(m) ### Example: for module load on supercomputers preload <- "module load r; " # e.g. via module load r start_rr(m, preload = preload) check_rr(m) kill_rr(m)

srpc 13 ## End(Not run) srpc Secure Remote Procedure Call Launch a command via ssh or plink on a (remote) server. srpc(cmd = "whoami", exec.type =.pbd_env$rpc.li$exec.type, args =.pbd_env$rpc.li$args, pport =.pbd_env$rpc.li$pport, user =.pbd_env$rpc.li$user, hostname =.pbd_env$rpc.li$hostname, priv.key =.pbd_env$rpc.li$priv.key, priv.key.ppk =.pbd_env$rpc.li$priv.key.ppk, intern =.pbd_env$rpc.ct$intern, wait =.pbd_env$rpc.ct$wait) cmd exec.type args pport user hostname the command to be executed on the server. either "ssh" or "plink" in character. Windows will force to use "plink". further arguments to "ssh" or "plink" for connecting to the server in addition to port, user id, and host name. ssh port opened on the server. user id for logging to the server. the server ip or host name. priv.key, priv.key.ppk location of the private key for user authentication, the file will be checked first then -i priv.key will be added to args when the file exists. priv.key.ppk is only used when plink is called. intern, wait arguments passed to system() or shell() whereever they are applicable. Using either ssh or plink to launch a command on a (remote) server. Authentication is working currently for ssh. NO further input from stdin is expected. Outputs or errors may not be captured by R.

14 ssh_plink Mainly the message received from the command line of server may be returned but may not be captured by R. For example, Windows with plink will not capture the return because currently the authentication is not working. A windows bat file is launched by shell.exec() in an additional cmd.exe window to avoid saving password inside R. See Also start_rr(), check_rr(), kill_rr(), ssh(), and plink(). Examples ## Not run: library(pbdrpc, quietly = TRUE) rpcopt_set(user = "snoweye", hostname = "192.168.56.101") ### see start_rr(), check_rr(), and kill_rr() for more examples. srpc() srpc("ls") srpc("ls ~/work-my") srpc("cat ~/work-my/00_set_devel_r") ### see ssh(), plink(), and run_args() for lower level examples. ### Local port forwarding srpc(args = "-N -T -L 55555:localhost:55555") start_rr() library(remoter) client() # equivalent to client(addr = "192.168.56.101") ## End(Not run) ssh_plink ssh and plink Commend line tools including ssh for Linux, Mac OSX, Solaris, or plink for Windows. 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",

ssh_plink 15 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) args intern, wait All in text/characters that are passed to the command line. 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 exec if pause when shell.exec is used in Windows. either ssh (i.e. /usr/bin/ssh) or a full path to plink. 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. Mainly the message received at the command line will be returned. Examples ## 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")

16 tunnel ### 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) ## End(Not run) tunnel tunnel tunnel tunnel(pport =.pbd_env$rpc.li$pport, user =.pbd_env$rpc.li$user, hostname =.pbd_env$rpc.li$hostname, priv.key =.pbd_env$rpc.li$priv.key, priv.key.ppk =.pbd_env$rpc.li$priv.key.ppk, lport = 55555, rport = 55555, rhostname = "127.0.0.1") pport, user, priv.key, priv.key.ppk See?pbdRPC::srpc. hostname lport, rport rhostname the server ip or host name. local and remote ports. the local ip or host name.

Index Topic global RPC Control Environment, 6 RPC Control Functions, 7 Topic package pbdrpc-package, 2 Topic programming Initial Control Functions, 3 Topic variables RPC Control Environment, 6 RPC Control Functions, 7.pbd_env, 7.pbd_env (RPC Control Environment), 6.rpcopt_init, 7.rpcopt_init (Initial Control Functions), 3 check_cs, 7 check_cs (rpc_cs_example), 8 check_exec (ssh_plink), 14 check_rr, 6, 7, 14 check_rr (rpc_rr_example), 11 checkx_rr, 7 checkx_rr (rpc_rr_example), 11 find_plink, 2 Initial Control Functions, 3 kill_cs, 7 kill_cs (rpc_cs_example), 8 kill_rr, 6, 7, 14 kill_rr (rpc_rr_example), 11 killx_rr, 7 killx_rr (rpc_rr_example), 11 print.machine (print-machine), 5 rpc, 5, 10 RPC Control Environment, 6 RPC Control Functions, 7 RPC.CT (RPC Control Functions), 7 RPC.LI (RPC Control Functions), 7 RPC.RR (RPC Control Functions), 7 rpc_cs_example, 8 rpc_kill (rpc_pid), 10 rpc_options, 9 rpc_pid, 10 rpc_ps (rpc_pid), 10 rpc_rr_example, 11 rpcopt_get (rpc_options), 9 rpcopt_set (rpc_options), 9 run_args (ssh_plink), 14 srpc, 6, 7, 10, 13 ssh, 6, 7, 14 ssh (ssh_plink), 14 ssh_plink, 14 start_cs, 7 start_cs (rpc_cs_example), 8 start_rr, 6, 7, 14 start_rr (rpc_rr_example), 11 startx_rr, 7 startx_rr (rpc_rr_example), 11 tunnel, 16 machine, 4, 6 pbdrpc-package, 2 plink, 6, 7, 14 plink (ssh_plink), 14 print-machine, 5 17