Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var telnet = require('telnet-client'); //Includes telnet-client
- var connection = new telnet(); //Creates new telnet object titled "connection"
- var params = { //Establishes params variable, to send the necessary argument parameters
- host: 'devnetcool.cciops.com', //hostname
- port: 22, //Sets listening port
- loginPrompt: 'login: ', //sets login prompt value
- passwordPrompt: 'Password: ', //sets password prompt value
- username: 'Vanguard', //defines initial value for login
- password: 'fL@sh3!', //defines initial value for password
- timeout: 3500, //sets timeout threshold
- };
- connection.on('ready', function(prompt) { //On session "Ready", execute prompt function
- connection.exec(cmd, function(err, response) {
- console.log(response);
- });
- });
- connection.on('timeout', function() { //On session timeout, display "Socket timeout!" and end connection
- console.log('socket timeout!')
- connection.end();
- });
- connection.on('close', function() { //On session close, display "Connection Closed"
- console.log('connection closed');
- });
- connection.connect(params); //On session connect, define arguments as var params
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement