1.0.0 • Published 7 years ago
expect-telnet v1.0.0
expect-telnet
telnet automation through expect-send sequences, like in Tcl.
Installation
$ npm install --save expect-telnetExamples
Log the output of a command
var et = require("expect-telnet");
et("1.2.3.4:23", [
{expect: "Username", send: "username\r"},
{expect: "Password", send: "password\r"},
{expect: "#" , send: "command\r" },
{expect: "#" , out: function(output) {
console.log(output);
}, send: "exit\r"}
], function(err) {
if (err) console.error(err);
});Start an interactive session
var et = require("expect-telnet");
et("1.2.3.4:23", [
{expect: "Username", send: "username\r"},
{expect: "Password", send: "password\r"},
{expect: "#" , interact: true }
], {exit: true}, function(err) {
if (err) console.error(err);
});API
expect-telnet(dest, seq, opts, cb)
deststring : Target host and port separated by a colon.seqarray : Array of expect steps (objects).optsobject : Options object.cbfunction: Called when an error happens.
Expect step object
expectstring / regexp : String or RegExp to expect.sendstring : String to send whenexpectis found.outfunction: Output function, receives the output since the previous step.interactboolean : Enter interacive mode with stdin/stdout. There's currently no way out of this mode, so this should be last.
Options
timeout*number: Timeout for connection and expect sequences in milliseconds. Set toinfinityfor no timeout.exitboolean: Whether to exit the process when interacting ends.
© silverwind, distributed under BSD licence
1.0.0
7 years ago
0.5.6
8 years ago
0.5.5
9 years ago
0.5.4
9 years ago
0.5.3
9 years ago
0.5.2
10 years ago
0.5.1
10 years ago
0.5.0
10 years ago
0.4.1
10 years ago
0.4.0
10 years ago
0.3.0
10 years ago
0.2.2
10 years ago
0.2.1
10 years ago
0.2.0
10 years ago
0.1.3
10 years ago
0.1.2
10 years ago
0.1.1
11 years ago
0.1.0
11 years ago