cp.remote: scp wrapper

Description Usage Arguments Examples

View source: R/cp.R

Description

A wrapper around the scp shell command that handles local/remote files and allows copying between remote hosts via the local machine.

Usage

1
2
cp.remote(remote.src, path.src, remote.dest, path.dest, verbose = FALSE,
  via.local = FALSE, local.temp.dir = tempdir())

Arguments

remote.src

Remote machine for the source file in the format [email protected] or an empty string for local.

path.src

Path of the source file.

remote.dest

Remote machine for the destination file in the format [email protected] or an empty string for local.

path.dest

Path for the source file; can be a directory.

verbose

Prints elapsed time if TRUE

via.local

Copies the file via the local machine. Useful when two remote machines can't talk to each other directly.

local.temp.dir

When copying via local machine, the directory to use as scratch space.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
## Not run: 
## Copy file myfile.csv from the home directory on the remote server to
## the local working directory.

## on remote server in bash shell:
# cat myfile.csv
# [[email protected] ~]$ cat myfile.csv
# "val","ts"
# 1,
# 2,
# 3,
# 4,
# 5,
# 6,
# 7,
# 8,
# 9,
# 10,

## on local server in R:
cp.remote(remote.src = "[email protected]", path.src = "~/myfile.csv",
          remote.dest = "", path.dest = getwd(), verbose = TRUE)
# [1] "Elapsed: 1.672 sec"
df <- read.csv("myfile.csv")
df
#    val ts
# 1    1 NA
# 2    2 NA
# 3    3 NA
# 4    4 NA
# 5    5 NA
# 6    6 NA
# 7    7 NA
# 8    8 NA
# 9    9 NA
# 10  10 NA

## End(Not run)

ssh.utils documentation built on May 29, 2017, 9:29 p.m.