replutil
v0.0.3
Published
[![npm](http://img.shields.io/badge/available%20on-npm-lightgrey.svg?logo=npm&logoColor=white)](https://www.npmjs.com/package/replutil) [![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno)](https://deno.land/x/repl
Downloads
4
Readme
replutil
REPL (Read-eval-print loop) utilities.
Usage
Use Sender
to send message to REPL and Receiver
to receive message from
REPL.
SSH
import { Receiver, Sender } from "./mod.ts";
const proc = Deno.run({
cmd: ["ssh", "-tt", "localhost", "/bin/sh"],
stdin: "piped",
stdout: "piped",
});
const receiver = new Receiver(proc.stdout, {
pattern: /.*\$ $/,
});
const sender = new Sender(proc.stdin);
await receiver.recv();
await sender.send("ls -al\n");
const received = await receiver.recv();
await sender.send("exit\n");
await proc.status();
proc.close();
console.log("-".repeat(80));
console.log(received);
console.log("-".repeat(80));
Telnet
import { Receiver, Sender } from "./mod.ts";
const username = "johntitor";
const password = "steinsgate";
const proc = Deno.run({
cmd: ["telnet", "localhost"],
stdin: "piped",
stdout: "piped",
});
const receiver = new Receiver(proc.stdout, {
pattern: /.* % /,
});
const sender = new Sender(proc.stdin);
await receiver.recv(/login: $/);
await sender.send(`${username}\n`);
await receiver.recv(/Password:$/);
await sender.send(`${password}\n`);
await receiver.recv();
await sender.send("ls -al\n");
const received = await receiver.recv();
await sender.send("exit\n");
await proc.status();
proc.close();
console.log("-".repeat(80));
console.log(received);
console.log("-".repeat(80));
Development
Lint code like:
make lint
Format code like
make fmt
Check types like
make type-check
Run tests like:
make test
License
The code follows MIT license written in LICENSE. Contributors need to agree that any modifications sent in this repository follow the license.