Skip to content

Commit 7971cad

Browse files
author
Cam Pedersen
committed
[major] working get
1 parent d20270c commit 7971cad

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

scp.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,31 @@
44
*/
55
var exec = require('child_process').exec;
66

7-
var scp = {};
7+
var scp = module.exports = {};
88

9+
/*
10+
* Transfer a file to a remote host
11+
*/
912
scp.send = function (options, cb) {
10-
13+
exec ('scp ', function () {
14+
cb(arguments);
15+
});
1116
}
1217

18+
/*
19+
* Grab a file from a remote host
20+
*/
1321
scp.get = function (options, cb) {
14-
22+
var command = [
23+
'scp',
24+
options.host + ':' + options.file,
25+
options.path
26+
];
27+
exec(command.join(' '), function (err, stdout, stderr) {
28+
if (cb) {
29+
cb(err, stdout, stderr);
30+
} else {
31+
if (err) throw new Error(err);
32+
}
33+
});
1534
}
16-
17-
module.exports = scp;

0 commit comments

Comments
 (0)