nl_tokens: Run a single SSH command and returns the result . When fullfilled the promise result is an object with the following properties :
pl_tokens: function sshExecSingleCommand ( cnxParams , cmd , fnOutput ) { var result = { "command" : cmd , "success" : <mask> , "error" : null , "value" : null } ; return Q . promise ( function ( resolve , reject ) { var sshClient = new SSHClient ( ) ; sshClient . on ( 'ready' , function ( ) { // sshClient Ready var stdout = "" ; var stderr = "" ; sshClient . exec ( cmd , function ( err , stream ) { if ( err ) { throw err ; } stream . on ( 'close' , function ( code , signal ) { sshClient . end ( ) ; if ( code !== 0 ) { result . success = false ; result . error = { "stderr" : stderr , "code" : code } ; reject ( result ) ; } else if ( fnOutput && typeof fnOutput === 'function' ) { result . value = fnOutput ( stdout ) ; resolve ( result ) ; } else { result . value = stdout ; resolve ( result ) ; } } ) . on ( 'data' , function ( data ) { stdout += data ; } ) . stderr . on ( 'data' , function ( data ) { stderr += data ; } ) ; } ) ; } ) . on ( 'error' , function ( error ) { // sshClient Error result . success = false ; result . error = error ; reject ( result ) ; } ) . connect ( cnxParams ) ; // sshClient Connect } ) ; }