当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Client.on方法代码示例

本文整理汇总了TypeScript中ssh2.Client.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Client.on方法的具体用法?TypeScript Client.on怎么用?TypeScript Client.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ssh2.Client的用法示例。


在下文中一共展示了Client.on方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: Client

socks.createServer( (info: any, accept: any, deny: any) => {
    // NOTE: you could just use one ssh2 client connection for all forwards, but
    // you could run into server-imposed limits if you have too many forwards open
    // at any given time
    var conn = new Client();
    conn.on('ready', () => {
        conn.forwardOut(info.srcAddr,
            info.srcPort,
            info.dstAddr,
            info.dstPort,
             (err: Error, stream: ssh2.ClientChannel) => {
                if (err) {
                    conn.end();
                    return deny();
                }

                var clientSocket: any;
                if (clientSocket = accept(true)) {
                    stream.pipe(clientSocket).pipe(stream).on('close', () => {
                        conn.end();
                    });
                } else
                    conn.end();
            });
    }).on('error', (err: Error) => {
        deny();
    }).connect(ssh_config);
}).listen(1080, 'localhost', () => {
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:28,代码来源:ssh2-tests.ts

示例2: Client

    return new Promise<PromiseSFTP>((resolve, reject) => {
      const client = new Client();

      client.on("error", reject);
      client.on("ready", () => {
        client.sftp((err: Error, sftp: SFTPWrapper) => {
          if (err) {
            reject(err);
          }

          resolve(new PromiseSFTP(sftp, client));
        });
      });

      client.connect(config);
    });
开发者ID:linusnorton,项目名称:uk-rail-import,代码行数:16,代码来源:PromiseSFTP.ts

示例3: setupSshClientConnection

export function setupSshClientConnection(sshConfig: any) : Q.Promise<any> {
    var defer = Q.defer<any>();
    var client = new Ssh2Client();
    client.on('ready', () => {
        defer.resolve(client);
    }).on('error', (err) => {
        defer.reject(err);
    }).connect(sshConfig);
    return defer.promise;
}
开发者ID:bleissem,项目名称:vsts-tasks,代码行数:10,代码来源:ssh2helpers.ts

示例4: initialize

function initialize() {
    conn = new Client();

    conn.on('ready', function () {
        console.log('conn::ready');
        conn.exec('gerrit stream-events', function (err, stream) {
            console.log('gerrit stream-events');
            if (err) {
                console.log('gerrit stream-events error', err);
                return reConnect();
            }
            stream.on('close', () => {
                console.log('stream::close');
            });
            stream.on('error', (err) => {
                console.log('stream::error', err);
            });
            stream.on('data', (data) => {
                console.log('stream::data', data + '');
                pushData(data);
            });
        });
    });
    conn.on('close', (hadError) => {
        console.log('conn::close');
    });

    conn.on('end', () => {
        console.log('conn::end');
    });

    conn.on('error', (err) => {
        console.log('conn::error', err + '');
        conn.end();
        reConnect();
    });

    connect();
}
开发者ID:adasq,项目名称:gerrit-native-notifications,代码行数:39,代码来源:ssh-stream.ts

示例5: cleanupTable

function cleanupTable(resolve, reject) {
  var conn = new Client();
  conn.on('ready', function() {
    console.log(chalk.bold.green('Connected to node1 as root'));
    conn.shell(function(err, stream) {
      if (err) throw err;
      stream.on('close', function() {
        if (errorMsg.length > 0) {
          console.log(chalk.bold.red('Error is:') + errorMsg);
          console.log(chalk.red.bgBlack.bold('Unable to truncate metron_update table in HBase. Most likely reason is HBase is down !!!'));
          reject();
        } else {
          console.log(chalk.bold.green('Truncated metron_update table in HBase'));
          resolve();
        }
        conn.end();
      }).on('data', function(data) {
        console.log('STDOUT: ' + data);
        if (data.indexOf('ERROR') !== -1) {
          errorMsg = data;
        }
      }).stderr.on('data', function(data) {
        console.log('STDERR: ' + data);
      });
      var comands = [
        'echo \'truncate "metron_update"\' | /usr/hdp/current/hbase-master/bin/hbase shell',
        'exit',
        ''
      ];
      stream.end(comands.join('\r\n'));
    });
  }).connect({
    host: 'node1',
    port: 22,
    username: 'root',
    password: 'vagrant'
  });
}
开发者ID:JonZeolla,项目名称:incubator-metron,代码行数:38,代码来源:clean_metron_update_table.ts

示例6: require

// # Client Examples
//

// Authenticate using keys and execute uptime on a server:

var Client = require('ssh2').Client;

var conn = new Client();
conn.on('ready', () => {
    console.log('Client :: ready');
    conn.exec('uptime', (err: Error, stream: ssh2.ClientChannel) => {
        if (err) throw err;
        stream
            .on('close', (code: any, signal: any) => {
                console.log('Stream :: close :: code: ' + code + ', signal: ' + signal);
                conn.end();
            }).on('data', (data: any) => {
                console.log('STDOUT: ' + data);
            }).stderr.on('data', (data: any) => {
                console.log('STDERR: ' + data);
            });
    });
}).connect({
    host: '192.168.100.100',
    port: 22,
    username: 'frylock',
    privateKey: require('fs').readFileSync('/here/is/my/key')
});

// Authenticate using keys and start an interactive shell session:
开发者ID:Jeremy-F,项目名称:DefinitelyTyped,代码行数:30,代码来源:ssh2-tests.ts


注:本文中的ssh2.Client.on方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。