Skip to content

Commit 210c231

Browse files
committed
Backup. Test later.
1 parent 90ba20c commit 210c231

21 files changed

+209
-77
lines changed

NAMESPACE

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export(kill_cs)
1313
export(kill_rr)
1414
export(machine)
1515
export(plink)
16+
export(rpc)
17+
export(rpc_kill)
18+
export(rpc_ps)
1619
export(rpcopt_get)
1720
export(rpcopt_set)
1821
export(run_args)

R/rpc.r

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#' \code{\link{srpc}()},
3333
#' \code{\link{ssh}()}, and \code{\link{plink}()}.
3434
#'
35+
#' @export
3536
rpc <- function(machine, cmd = "whoami", intern = .pbd_env$RPC.CT$intern,
3637
wait = .pbd_env$RPC.CT$wait)
3738
{

R/rpc_cs_example.r

+11-10
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,26 @@
4747
#' @examples
4848
#' \dontrun{
4949
#' library(pbdRPC, quietly = TRUE)
50-
#' rpcopt_set(user = "snoweye", hostname = "192.168.56.101")
50+
#' # rpcopt_set(user = "snoweye", hostname = "192.168.56.101")
51+
#' m <- machine(user = "snoweye", hostname = "192.168.56.101")
5152
#'
52-
#' check_cs() # pid 2857 (may differ)
53-
#' kill_cs() # all pbdCS pids are killed
54-
#' check_cs() # make sure no pbdCS R cluster is running
53+
#' check_cs(m) # pid 2857 (may differ)
54+
#' kill_cs(m) # all pbdCS pids are killed
55+
#' check_cs(m) # make sure no pbdCS R cluster is running
5556
#'
5657
#' ### use "; " to bypass multiple commands
5758
#' preload <- "source ~/work-my/00_set_devel_R; "
5859
#'
5960
#' ### start a new pbdCS R cluster
60-
#' start_cs(preload = preload)
61-
#' check_cs()
62-
#' kill_cs()
61+
#' start_cs(m, preload = preload)
62+
#' check_cs(m)
63+
#' kill_cs(m)
6364
#'
6465
#' ### Example: for module load on supercomputers
6566
#' preload <- "module load r; " # e.g. via module load r
66-
#' start_cs(preload = preload)
67-
#' check_cs()
68-
#' kill_cs()
67+
#' start_cs(m, preload = preload)
68+
#' check_cs(m)
69+
#' kill_cs(m)
6970
#' }
7071
#'
7172
#'

R/rpc_pid.r

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#' Search or Kill pid of Remote Procedure Call
2+
#'
3+
#' Search or kill possible pid's that running remote procedure calls
4+
#' in background.
5+
#'
6+
#' @param pid
7+
#' a vector containing proccess id's in interger.
8+
#'
9+
#' @details
10+
#' \code{rpc_ps()} prints possible pid's that running remote procedure
11+
#' calls in background via one of
12+
#' \code{ssh}, \code{plink}, \code{plink.exe}, or \code{cmd.exe}.
13+
#'
14+
#' \code{rpc_kill()} kill pid's.
15+
#'
16+
#' @return
17+
#' List or kill all possible pid's.
18+
#'
19+
#' @rdname rpc_pid
20+
#' @name rpc_pid
21+
NULL
22+
23+
24+
#' @rdname rpc_pid
25+
#' @export
26+
rpc_ps <- function()
27+
{
28+
if (.Platform$OS.type == "windows")
29+
{
30+
pid <- system('Tasklist /FI "IMAGENAME eq plink.exe"', intern = TRUE)
31+
cat(pid, sep = "\n")
32+
pid <- system('Tasklist /FI "IMAGENAME eq cmd.exe"', intern = TRUE)
33+
cat(pid, sep = "\n")
34+
}
35+
else
36+
{
37+
pid <- system("/bin/ps uxww", intern = TRUE)
38+
pid <- grep("(ssh|plink) ", pid, value = TRUE)
39+
cat(pid, sep = "\n")
40+
}
41+
42+
return(invisible())
43+
}
44+
45+
46+
#' @rdname rpc_pid
47+
#' @export
48+
rpc_kill <- function(pid)
49+
{
50+
tools::pskill(pid)
51+
}

R/rpc_rr_example.r

+11-10
Original file line numberDiff line numberDiff line change
@@ -46,25 +46,26 @@
4646
#' @examples
4747
#' \dontrun{
4848
#' library(pbdRPC, quietly = TRUE)
49-
#' rpcopt_set(user = "snoweye", hostname = "192.168.56.101")
49+
#' # rpcopt_set(user = "snoweye", hostname = "192.168.56.101")
50+
#' m <- machine(user = "snoweye", hostname = "192.168.56.101")
5051
#'
51-
#' check_rr() # pid 2857 (may differ)
52-
#' kill_rr() # all remoter pids are killed
53-
#' check_rr() # make sure no remoter servers are running
52+
#' check_rr(m) # pid 2857 (may differ)
53+
#' kill_rr(m) # all remoter pids are killed
54+
#' check_rr(m) # make sure no remoter servers are running
5455
#'
5556
#' ### use "; " to bypass multiple commands
5657
#' preload <- "source ~/work-my/00_set_devel_R; "
5758
#'
5859
#' ### start a new remoter server
59-
#' start_rr(preload = preload)
60-
#' check_rr()
61-
#' kill_rr()
60+
#' start_rr(m, preload = preload)
61+
#' check_rr(m)
62+
#' kill_rr(m)
6263
#'
6364
#' ### Example: for module load on supercomputers
6465
#' preload <- "module load r; " # e.g. via module load r
65-
#' start_rr(preload = preload)
66-
#' check_rr()
67-
#' kill_rr()
66+
#' start_rr(m, preload = preload)
67+
#' check_rr(m)
68+
#' kill_rr(m)
6869
#' }
6970
#'
7071
#'

R/srpc.r

+5-5
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@
5151
#' rpcopt_set(user = "snoweye", hostname = "192.168.56.101")
5252
#'
5353
#' ### see start_rr(), check_rr(), and kill_rr() for more examples.
54-
#' rpc()
55-
#' rpc("ls")
56-
#' rpc("ls ~/work-my")
57-
#' rpc("cat ~/work-my/00_set_devel_R")
54+
#' srpc()
55+
#' srpc("ls")
56+
#' srpc("ls ~/work-my")
57+
#' srpc("cat ~/work-my/00_set_devel_R")
5858
#'
5959
#' ### see ssh(), plink(), and run_args() for lower level examples.
6060
#'
6161
#' ### Local port forwarding
62-
#' rpc(args = "-N -T -L 55555:localhost:55555")
62+
#' srpc(args = "-N -T -L 55555:localhost:55555")
6363
#' start_rr()
6464
#'
6565
#' library(remoter)

R/ssh_plink.r

+6
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,12 @@ run_args <- function(exec = "ssh", args = "",
153153
cat(cmd, file = cmd.fn, sep = "\n")
154154

155155
ret <- shell.exec(cmd.fn)
156+
157+
pid <- system('Tasklist /FI "IMAGENAME eq plink.exe"', intern = TRUE)
158+
cat(pid, sep = "\n")
159+
pid <- system('Tasklist /FI "IMAGENAME eq cmd.exe"', intern = TRUE)
160+
cat(pid, sep = "\n")
161+
156162
return(invisible(ret))
157163
}
158164
else

inst/doc/pbdRPC-guide.Rnw

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ Silver Spring, MD, USA \\
9090

9191
\input{./pbdRPC-include/02-introduction}
9292
\input{./pbdRPC-include/03-login_information}
93+
\input{./pbdRPC-include/08-machine_information}
9394
\input{./pbdRPC-include/04-application_rr}
9495
\input{./pbdRPC-include/05-application_cs}
9596
\input{./pbdRPC-include/06-port_forwarding}

inst/doc/pbdRPC-guide.pdf

-50.1 KB
Binary file not shown.

man/rpc_cs_example.Rd

+11-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/rpc_pid.Rd

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/rpc_rr_example.Rd

+11-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/srpc.Rd

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vignettes/pbdRPC-guide.Rnw

+1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ Silver Spring, MD, USA \\
9090

9191
\input{./pbdRPC-include/02-introduction}
9292
\input{./pbdRPC-include/03-login_information}
93+
\input{./pbdRPC-include/08-machine_information}
9394
\input{./pbdRPC-include/04-application_rr}
9495
\input{./pbdRPC-include/05-application_cs}
9596
\input{./pbdRPC-include/06-port_forwarding}

vignettes/pbdRPC-include/02-introduction.tex

+6-5
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
For Windows system, one may use \code{plink.exe} instead of \code{ssh}
103103
from a terminal \code{cmd.exe}. See Section~\ref{sec:basic_plink} for details.
104104
105-
Within \proglang{R}, the next example will have the
105+
Within \proglang{R}, the example below will have the
106106
same results as the above shell command.
107107
\begin{Code}[title=Basic \code{srpc()} in \pkg{pbdRPC} and \proglang{R}]
108108
> library(pbdRPC, quietly = TRUE)
@@ -122,7 +122,7 @@
122122
detects the system first, then calls the corresponding function.
123123
Currently, no external \code{plink.exe} or \code{plink} is implemented
124124
even though it is possible.
125-
The details of \code{ssh()} and \code{plink()} are given in next.
125+
The details of \code{ssh()} and \code{plink()} are given in examples below.
126126
127127
128128
\subsection[Basic \code{ssh()}]{Basic \code{ssh()}}
@@ -141,7 +141,7 @@
141141
Note that multiple commands can be automatically given at once
142142
as shell commands under an shell prompt, such as ``\code{;}'', ``\code{\&\&}'',
143143
``\code{>}'', ``\code{<}'', ``\code{|}'' or ``\code{\&}'' etc.
144-
For example, the next will tell current id, date/time, and files.
144+
For example, the code below will tell current id, date/time, and files.
145145
\begin{Command}[title=Multiple commands to \code{ssh} in shell]
146146
$ ssh snoweye@192.168.56.101 'whoami;date;ls -a'
147147
\end{Command}
@@ -158,7 +158,8 @@
158158
\label{sec:basic_plink}
159159
\addcontentsline{toc}{subsection}{\thesubsection. Basic \code{plink.exe}\ and \code{plink()}}
160160
161-
In Windows system and inside the \code{cmd.exe}, one may similarly use next
161+
In Windows system and inside the \code{cmd.exe}, one may similarly use
162+
the code below
162163
\begin{Command}[title=Basic \code{plink.exe} in \code{cmd.exe}]
163164
C:\> plink.exe snoweye@192.168.56.101 'whoami'
164165
\end{Command}
@@ -177,7 +178,7 @@
177178
command \code{whoami} because the password input is not allowed inside
178179
\code{RGui}.
179180
When the authentication file (\code{id_rsa.ppk}) is available,
180-
one may want to disable the opening \code{cmd.exe} as in next.
181+
one may want to disable the opening \code{cmd.exe} below.
181182
\begin{Code}[title=Advance \code{plink()} in \pkg{pbdRPC} and \proglang{R}]
182183
> .pbd_env$RPC.CT$use.shell.exec <- FALSE
183184
> ret <- plink("snoweye@192.168.56.101 'whoami'")

vignettes/pbdRPC-include/03-login_information.tex

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
respectively.
1313
Suppose further the login id is called ``snoweye'', then one may use
1414
the function \code{rpcopt_set()} to assign/overwrite the login information to
15-
\code{.pbd_env$RPC.LI} as in next.
15+
\code{.pbd_env$RPC.LI} below.
1616
\begin{Code}[title=Set login information]
1717
> ### Alter login information as needed
18-
> rpcopt_set(user = "snoweye", hostname = "192.168.56.101", pport = "22")
18+
> rpcopt_set(user = "snoweye", hostname = "192.168.56.101", pport = 22)
1919
\end{Code}
2020
21-
In next, the basic login information \code{RPC.LI} describes that
21+
The basic login information \code{RPC.LI} below describes that
2222
\code{srpc()} will
2323
\begin{itemize}
2424
\item use \code{ssh} (exec.type) to execute a command
@@ -39,7 +39,7 @@
3939
[1] ""
4040

4141
$pport
42-
[1] "22"
42+
[1] 22
4343
4444
$user
4545
[1] "snoweye"

0 commit comments

Comments
 (0)