Advertisement
Guest User

Untitled

a guest
May 4th, 2017
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var telnet = require('telnet-client'); //Includes telnet-client
  2. var connection = new telnet(); //Creates new telnet object titled "connection"
  3.  
  4. var params = { //Establishes params variable, to send the necessary argument parameters
  5.   host: 'devnetcool.cciops.com', //hostname
  6.   port: 22, //Sets listening port
  7.   loginPrompt: 'login: ', //sets login prompt value
  8.   passwordPrompt: 'Password: ', //sets password prompt value
  9.   username: 'Vanguard', //defines initial value for login
  10.   password: 'fL@sh3!', //defines initial value for password
  11.   timeout: 3500, //sets timeout threshold
  12. };
  13.  
  14. connection.on('ready', function(prompt) { //On session "Ready", execute prompt function
  15.   connection.exec(cmd, function(err, response) {
  16.     console.log(response);
  17.   });
  18. });
  19.  
  20. connection.on('timeout', function() { //On session timeout, display "Socket timeout!" and end connection
  21.   console.log('socket timeout!')
  22.   connection.end();
  23. });
  24.  
  25. connection.on('close', function() { //On session close, display "Connection Closed"
  26.   console.log('connection closed');
  27. });
  28.  
  29. connection.connect(params); //On session connect, define arguments as var params
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement