<commit_before>/**
# cp-remote&nbsp;&nbsp;&nbsp;[![Build Status](https://travis-ci.org/davedoesdev/cp-remote.png)](https://travis-ci.org/davedoesdev/cp-remote) [![Coverage Status](https://coveralls.io/repos/davedoesdev/cp-remote/badge.png?branch=master)](https://coveralls.io/r/davedoesdev/cp-remote?branch=master) [![NPM version](https://badge.fury.io/js/cp-remote.png)](http://badge.fury.io/js/cp-remote)

Node.js [`child_process`](http://nodejs.org/api/child_process.html) done remotely, IPC channel intact!

Example:

```javascript
var cp_remote = require('cp-remote');
var remote = cp_remote.run('host', '/path/on/host/to/sub.js', 'foo', { answer: 42 });
remote.on('message', function (msg)
{
    assert.deepEqual(msg, { foo: 'bar' });
});
remote.send({ hello: 'world' });
```

You might implement the remote script, `sub.js`, like this:

```javascript
assert.equal(process.argv[2], 'foo')
assert.equal(process.argv[3], { answer: 42 });
process.on('message', function (msg)
{
    assert.deepEqual(msg, { hello: 'world' });
});
process.send({ foo: 'bar' });
```

## Pre-requisites

Client:

- SSH client (e.g. [OpenSSH](http://www.openssh.com)), configured for password-less logon to the remote host (e.g. using a private key).
- [Node.js](http://www.nodejs.org) (of course)
- [Bash](https://www.gnu.org/software/bash/bash.html)
- [socat](http://www.dest-unreach.org/socat/)

Remote host:

- SSH server (e.g. [OpenSSH](http://www.openssh.com))
- Node.js (`node` command should be in the remote `PATH` of SSH sessions)
- [Python](http://www.python.org) (it provides access to [`socketpair`](http://pubs.opengroup.org/onlinepubs/009695399/functions/socketpair.html), Node does not)
- [socat](http://www.dest-unreach.org/socat/)

## Installation

```shell
npm install cp-remote
```

## Limitation

You can't pass handles to a remote child process like you can with local child processes.<commit_msg>Fix example<commit_after>/**
# cp-remote&nbsp;&nbsp;&nbsp;[![Build Status](https://travis-ci.org/davedoesdev/cp-remote.png)](https://travis-ci.org/davedoesdev/cp-remote) [![Coverage Status](https://coveralls.io/repos/davedoesdev/cp-remote/badge.png?branch=master)](https://coveralls.io/r/davedoesdev/cp-remote?branch=master) [![NPM version](https://badge.fury.io/js/cp-remote.png)](http://badge.fury.io/js/cp-remote)

Node.js [`child_process`](http://nodejs.org/api/child_process.html) done remotely, IPC channel intact!

Example:

```javascript
var cp_remote = require('cp-remote');
var assert = require('assert');
var remote = cp_remote.run('host', '/path/on/host/to/sub.js', 'foo', { answer: 42 });
remote.on('message', function (msg)
{
    assert.deepEqual(msg, { foo: 'bar' });
});
remote.send({ hello: 'world' });
```

You might implement the remote script, `sub.js`, like this:

```javascript
var assert = require('assert');
assert.equal(process.argv[2], 'foo')
assert.deepEqual(process.argv[3], { answer: 42 });
process.on('message', function (msg)
{
    assert.deepEqual(msg, { hello: 'world' });
    process.disconnect();
});
process.send({ foo: 'bar' });
```

## Pre-requisites

Client:

- SSH client (e.g. [OpenSSH](http://www.openssh.com)), configured for password-less logon to the remote host (e.g. using a private key).
- [Node.js](http://www.nodejs.org) (of course)
- [Bash](https://www.gnu.org/software/bash/bash.html)
- [socat](http://www.dest-unreach.org/socat/)

Remote host:

- SSH server (e.g. [OpenSSH](http://www.openssh.com))
- Node.js (`node` command should be in the remote `PATH` of SSH sessions)
- [Python](http://www.python.org) (it provides access to [`socketpair`](http://pubs.opengroup.org/onlinepubs/009695399/functions/socketpair.html), Node does not)
- [socat](http://www.dest-unreach.org/socat/)

## Installation

```shell
npm install cp-remote
```

## Limitation

You can't pass handles to a remote child process like you can with local child processes.
{'fraction_non_alphanumeric': 0.20195272353545735, 'fraction_numerical': 0.007708119218910586, 'mean_word_length': 4.8104477611940295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 12, 'lorem ipsum': 0, 'www.': 14, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3965134', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1364, 'n_words': 273}